Steve Kemp > Redis-SQLite-0.3 > Redis::SQLite

Download:
Redis-SQLite-0.3.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.3   Source  

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:

HASH

For example hlen, hkeys, hexists, etc.

Lists

For example lset, ltrim, etc.

Scripting

Perl is itself a wonderful scripting language, so we've no need for Lua support.

ZSET

For example zcard, zadd, zcount, etc.

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:

append
del
exists
get
set
etc..

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.

getrange

Return the chunk of the key's value between the given offsets.

strlen

Return the length of the given value of the given key.

rename

Rename a string key. Deleting the target if it exists.

renamenx

Attempt to rename the given key, if the destination exists then nothing happens.

set

Set the value of a string-key.

setnx

Store the given value in the named key, unless that key exists.

setrange

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.

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" ]

randomkey

Return the name of a random key.

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.

bitcount

Count the number of set bits in the content of the given key.

ping

This would usually check if the Redis connection was alive, and the server was present, in this implementation we always return true.

echo

Return the parameters given.

mget

Return the values of multiple-keys. If a given key doesn't exist then undef will be returned for that entry.

mget

Update the values of multiple-keys.

mgetnx

Update the values of multiple-keys, only if all the keys don't already exist.

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.

syntax highlighting: