Redis - perl binding for Redis database
Pure perl bindings for http://code.google.com/p/redis/
This version support git version 0.08 or later of Redis available at
git://github.com/antirez/redis
This documentation lists commands which are exercised in test suite, but additinal commands will work correctly since protocol specifies enough information to support almost all commands with same peace of code with a little help of AUTOLOAD.
AUTOLOAD
my $r = Redis->new; # $ENV{REDIS_SERVER} or 127.0.0.1:6379 my $r = Redis->new( server => '192.168.0.1:6379', debug = 0 );
$r->quit;
$r->ping || die "no server?";
$r->set( foo => 'bar' ); $r->setnx( foo => 42 );
my $value = $r->get( 'foo' );
my @values = $r->mget( 'foo', 'bar', 'baz' );
$r->incr('counter'); $r->incrby('tripplets', 3);
$r->decr('counter'); $r->decrby('tripplets', 3);
$r->exists( 'key' ) && print "got key!";
$r->del( 'key' ) || warn "key doesn't exist";
$r->type( 'key' ); # = string
my @keys = $r->keys( '*glob_pattern*' );
my $key = $r->randomkey;
my $ok = $r->rename( 'old-key', 'new-key', $new );
my $nr_keys = $r->dbsize;
See also Redis::List for tie interface.
$r->rpush( $key, $value );
$r->lpush( $key, $value );
$r->llen( $key );
my @list = $r->lrange( $key, $start, $end );
my $ok = $r->ltrim( $key, $start, $end );
$r->lindex( $key, $index );
$r->lset( $key, $index, $value );
my $modified_count = $r->lrem( $key, $count, $value );
my $value = $r->lpop( $key );
my $value = $r->rpop( $key );
$r->sadd( $key, $member );
$r->srem( $key, $member );
my $elements = $r->scard( $key );
$r->sismember( $key, $member );
$r->sinter( $key1, $key2, ... );
my $ok = $r->sinterstore( $dstkey, $key1, $key2, ... );
$r->select( $dbindex ); # 0 for new clients
$r->move( $key, $dbindex );
$r->flushdb;
$r->flushall;
$r->sort("key BY pattern LIMIT start end GET pattern ASC|DESC ALPHA');
$r->save;
$r->bgsave;
$r->lastsave;
$r->shutdown;
my $info_hash = $r->info;
Dobrica Pavlinusic, <dpavlin at rot13.org>
<dpavlin at rot13.org>
Please report any bugs or feature requests to bug-redis at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Redis. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-redis at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Redis perldoc Redis::List perldoc Redis::Hash
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Redis
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Redis
CPAN Ratings
http://cpanratings.perl.org/d/Redis
Search CPAN
http://search.cpan.org/dist/Redis
Copyright 2009 Dobrica Pavlinusic, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Redis, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Redis
CPAN shell
perl -MCPAN -e shell install Redis
For more information on module installation, please visit the detailed CPAN module installation guide.