Redis::SQLite - Redis-Compatible module which writes to SQLite.
#!/usr/bin/perl -w use Redis::SQLite; use strict; my $db = Redis::SQLite->new(); $db->set( "foo", "bar" ); print $db->get( "foo" ) . "\n";
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.
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:
For example hlen, hkeys, hexists, etc.
hlen
hkeys
hexists
For example lset, ltrim, etc.
lset
ltrim
Perl is itself a wonderful scripting language, so we've no need for Lua support.
For example zcard, zadd, zcount, etc.
zcard
zadd
zcount
All of the set-related primitives are supported, with the exception of SSCAN, and the basic commands for working with string-based keys are also present, such as:
SSCAN
Constructor. The only (optional) argument is path which will change the default SQLite database-file location, if unspecified ~/.predis.db will be used.
path
~/.predis.db
Append the given string to the contents of the existing key, creating it if didn't previously exist.
Does the given key exist?
Get the value of a string-key. Returns undef if the key didn't exist, or contain data.
undef
Update the value of a key, and return the previous value if any.
Return the chunk of the key's value between the given offsets.
Return the length of the given value of the given key.
Rename a string key. Deleting the target if it exists.
Attempt to rename the given key, if the destination exists then nothing happens.
Set the value of a string-key.
Store the given value in the named key, unless that key exists.
Insert some new data at the given offset of the specific key's value.
If the current length of the key's value is too short it is NULL-padded first.
Return the type of the named key.
Increment and return the value of an (integer) string-key.
Decrement and return the value of an (integer) string-key.
Delete a given key, regardless of whether it holds a string or a set.
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" ]
Return the name of a random key.
Return the members of the given set.
Move a member from a given set to a new one.
Is the given item a member of the set?
Add a member to a set.
Remove a member from a set.
Remove a given number of elements from the named set, and return them.
Fetch the value of a random member from a set.
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 ]
Store the values which are present in each of the named sets in a new set.
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 ]
Store those members who exist in all the named sets in a new set.
Count the number of entries in the given set.
Count the number of set bits in the content of the given key.
This would usually check if the Redis connection was alive, and the server was present, in this implementation we always return true.
Return the parameters given.
Return the values of multiple-keys. If a given key doesn't exist then undef will be returned for that entry.
Update the values of multiple-keys.
Update the values of multiple-keys, only if all the keys don't already exist.
Steve Kemp
http://www.steve.org.uk/
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.
To install Redis::SQLite, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Redis::SQLite
CPAN shell
perl -MCPAN -e shell install Redis::SQLite
For more information on module installation, please visit the detailed CPAN module installation guide.