NAME

RedisDB - Module to access redis database

SYNOPSIS

use RedisDB;

my $redis = RedisDB->new(host => 'localhost', port => 6379);
$redis->set($key, $value);
my $value = $redis->get($key);

DESCRIPTION

This is alfa version, use on your own risk, interface is subject to change

This module provides interface to access redis database. It transparently handles disconnects and forks.

METHODS

$class->new(%options)

Creates new RedisDB object. The following options are allowed:

host

domain name of the host running redis server. Default: "localhost"

port

port to connect. Default: 6379

lazy

by default new establishes connection to the server. If this parameter is set, then connection will be established when you will send command to the server.

$self->execute($command, @arguments)

send command to the server and return server reply. It throws exception if server returns error.

$self->connect

establish connection to the server. There's usually no need to use this method, as connection is established by new or when you send a command.

$self->send_command($command, @arguments)

send command to the server. Returns true if command was successfully sent, or dies if error occured. Note, that it doesn't return server reply, you should retrieve reply using recv_reply method.

$self->recv_reply

receive reply from the server. Method returns two elements array. First element is the character depending on type of reply: "+" one line reply, "-" error, ":" integer reply, "$" bulk reply, "*" multi-bulk reply. Second element is reply itself, which is scalar for all replies, except that it is array reference for multi-bulk.

SUPPORTED REDIS COMMANDS

Usually, instead of using send_command and recv_reply methods, you can just use functions corresponding to redis commands: append auth bgrewriteaof bgsave blpop brpoplpush config_get config_set config_resetstat dbsize debug_object debug_segfault decr decrby del echo exists expire expireat flushall flushdb get getbit getrange getset hdel hexists hget hgetall hincrby hkeys hlen hmget hmset hset hsetnx hvals incr incrby info keys lastsave lindex linsert llen lpop lpush lpushx lrange lrem lset ltrim mget move mset msetnx persist ping publish quit randomkey rename renamenx rpop rpoplpush rpush rpushx sadd save scard sdiff sdiffstore select set setbit setex setnx setrange shutdown sinter sinterstore sismember slaveof smembers smove sort spop srandmember srem strlen sunion sunionstore sync ttl type zadd zcard zcount zincrby zinterstore zrange zrangebyscore zrank zremrangebyrank zremrangebyscore zrevrange zrevrangebyscore zrevrank zscore zunionstore

See description of these commands in redis documentation at http://redis.io/commands.

SEE ALSO

Redis, Redis::hiredis, AnyEvent::Redis

TODO

  • Test all commands

  • Better pipelining support

  • User defined error callback

  • Handle cases than client not interested in replies

  • Transactions support (MULTI, EXEC, DISCARD, WATCH, UNWATCH)

  • Subscriptions support (PSUBSCRIBE, PUNSUBSCRIBE, SUBSCRIBE, UNSUBSCRIBE)

  • MONITOR support

  • Non-blocking check if reply available

BUGS

Please report any bugs or feature requests to bug-redisdb at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=RedisDB. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

AUTHOR

Pavel Shaydo, <zwon at cpan.org>

LICENSE AND COPYRIGHT

Copyright 2011 Pavel Shaydo.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.