Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Exists functionality added.

  • Loading branch information...
commit ce4b12851d7295475bb7e401de023c9b8a32ff26 1 parent 2ac6f33
@symkat authored
Showing with 12 additions and 0 deletions.
  1. +9 −0 lib/Cache/SQLite.pm
  2. +3 −0  t/01_basic_functions.t
View
9 lib/Cache/SQLite.pm
@@ -103,4 +103,13 @@ sub hit {
return $self;
}
+sub exists {
+ my ( $self, $key ) = @_;
+ my $sth = $self->connection->prepare( "SELECT key FROM cache WHERE key = ? LIMIT 1" );
+ $sth->execute( $key );
+ my $row = $sth->fetchrow_hashref;
+ return 0 unless defined $row and $row->{key} eq $key;
+ return 1;
+}
+
1;
View
3  t/01_basic_functions.t
@@ -17,4 +17,7 @@ is $Cache->get( "Dr" ), "Who";
ok $Cache->purge( "hello" );
is $Cache->get( "hello" ), undef;
+is $Cache->exists( "Dr" ), 1;
+is $Cache->exists( "False" ), 0;
+
done_testing;
Please sign in to comment.
Something went wrong with that request. Please try again.