NAME
Redis::SQLite - Redis-Compatible module which writes to SQLite.
SYNOPSIS
#!/usr/bin/perl -w
use Redis::SQLite;
use strict;
my $db = Redis::SQLite->new();
$db->set( "foo", "bar" );
print $db->get( "foo" ) . "\n";
DESCRIPTION
This package is an implementation of the Redis Perl-client API, which stores all data in an SQLite database rather than in RAM.
It is not a drop-in replacement, because it doesn't implement all the features you'd expect from the real Redis module. Just enough to be useful.
COMPATIBILITY
This module is designed to be source compatible with the Redis module, providing you're only operating upon either sets or simple strings. Specifically we do not support ZSET or HASH-related operations.
The following methods are implemented as part of the basic-functionality:
- APPEND
- EXISTS
- GET
- GETSET
- SET
- TYPE
- INCR
- INCRBY
- DECR
- DECRBY
- DEL
- STRLEN
The following set-related methods are implemented:
- SADD
- SCARD
- SDIFF
- SDIFFSTORE
- SINTER
- SINTERSTORE
- SISMEMBER
- SMEMBERS
- SMOVE
- SPOP
- SRANDMEMBER
- SREM
- SUNION
- SUNIONSTORE
The only missing set-method is SSCAN
, other methods which are missing will raise a warn
ing.
METHODS
new
Constructor. The only (optional) argument is path
which will change the default SQLite database-file location, if unspecified ~/.predis.db
will be used.
append
Append the given string to the contents of the existing key, creating it if didn't previously exist.
exists
Does the given key exist?
get
Get the value of a string-key. Returns undef
if the key didn't exist, or contain data.
getset
Update the value of a key, and return the previous value if any.
strlen
Return the length of the given value of the given key.
set
Set the value of a string-key.
type
Return the type of the named key.
incr
Increment and return the value of an (integer) string-key.
incrby
Increment and return the value of an (integer) string-key.
decr
Decrement and return the value of an (integer) string-key.
decrby
Decrement and return the value of an (integer) string-key.
del
Delete a given key, regardless of whether it holds a string or a set.
keys
Return the names of each known key.
These can be optionally filtered by a (perl) regular expression, for example:
$redis->set( "foo", 1 );
$redis->set( "moo", 1 );
$redis->keys( "^f" ); # -> [ "foo" ]
$redis->keys( "oo\$" ); # -> [ "foo", "moo" ]
smembers
Return the members of the given set.
smove
Move a member from a given set to a new one.
sismember
Is the given item a member of the set?
sadd
Add a member to a set.
srem
Remove a member from a set.
spop
Remove a given number of elements from the named set, and return them.
srandmember
Fetch the value of a random member from a set.
sunion
Return the values which are present in each of the sets named, duplicates will only be returned one time.
For example:
$redis->sadd( "one", 1 );
$redis->sadd( "one", 2 );
$redis->sadd( "one", 3 );
$redis->sadd( "two", 2 );
$redis->sadd( "two", 3 );
$redis->sadd( "two", 4 );
$redis->sunion( "one", "two" ); # -> [ 1,2,3,4 ]
sunionstore
Store the values which are present in each of the named sets in a new set.
sinter
Return only those members who exist in each of the named sets.
$redis->sadd( "one", 1 );
$redis->sadd( "one", 2 );
$redis->sadd( "one", 3 );
$redis->sadd( "two", 2 );
$redis->sadd( "two", 3 );
$redis->sadd( "two", 4 );
$redis->sinter( "one", "two" ); # -> [ 2,3 ]
sinterstore
Store those members who exist in all the named sets in a new set.
scard
Count the number of entries in the given set.
AUTHOR
Steve Kemp
http://www.steve.org.uk/
LICENSE
Copyright (c) 2016 by Steve Kemp. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The LICENSE file contains the full text of the license.