++ed by:
RORYRJB DAMS ADAMJS WKI UNDEF

20 PAUSE users
19 non-PAUSE users.

Dobrica Pavlinušić

NAME

Redis - perl binding for Redis database

DESCRIPTION

Pure perl bindings for http://code.google.com/p/redis/

This version supports protocol 1.2 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.

FUNCTIONS

new

  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 );

Connection Handling

quit

  $r->quit;

ping

  $r->ping || die "no server?";

Commands operating on string values

set

  $r->set( foo => 'bar' );

  $r->setnx( foo => 42 );

get

  my $value = $r->get( 'foo' );

mget

  my @values = $r->mget( 'foo', 'bar', 'baz' );

incr

  $r->incr('counter');

  $r->incrby('tripplets', 3);

decr

  $r->decr('counter');

  $r->decrby('tripplets', 3);

exists

  $r->exists( 'key' ) && print "got key!";

del

  $r->del( 'key' ) || warn "key doesn't exist";

type

  $r->type( 'key' ); # = string

Commands operating on the key space

keys

  my @keys = $r->keys( '*glob_pattern*' );

randomkey

  my $key = $r->randomkey;

rename

  my $ok = $r->rename( 'old-key', 'new-key', $new );

dbsize

  my $nr_keys = $r->dbsize;

Commands operating on lists

See also Redis::List for tie interface.

rpush

  $r->rpush( $key, $value );

lpush

  $r->lpush( $key, $value );

llen

  $r->llen( $key );

lrange

  my @list = $r->lrange( $key, $start, $end );

ltrim

  my $ok = $r->ltrim( $key, $start, $end );

lindex

  $r->lindex( $key, $index );

lset

  $r->lset( $key, $index, $value );

lrem

  my $modified_count = $r->lrem( $key, $count, $value );

lpop

  my $value = $r->lpop( $key );

rpop

  my $value = $r->rpop( $key );

Commands operating on sets

sadd

  $r->sadd( $key, $member );

srem

  $r->srem( $key, $member );

scard

  my $elements = $r->scard( $key );

sismember

  $r->sismember( $key, $member );

sinter

  $r->sinter( $key1, $key2, ... );

sinterstore

  my $ok = $r->sinterstore( $dstkey, $key1, $key2, ... );

Multiple databases handling commands

select

  $r->select( $dbindex ); # 0 for new clients

move

  $r->move( $key, $dbindex );

flushdb

  $r->flushdb;

flushall

  $r->flushall;

Sorting

sort

  $r->sort("key BY pattern LIMIT start end GET pattern ASC|DESC ALPHA');

Persistence control commands

save

  $r->save;

bgsave

  $r->bgsave;

lastsave

  $r->lastsave;

shutdown

  $r->shutdown;

Remote server control commands

info

  my $info_hash = $r->info;

ENCODING

Since Redis knows nothing about encoding, we are forcing utf-8 flag on all data received from Redis. This change is introduced in 1.2001 version.

This allows us to round-trip utf-8 encoded characters correctly, but might be problem if you push binary junk into Redis and expect to get it back without utf-8 flag turned on.

AUTHOR

Dobrica Pavlinusic, <dpavlin at rot13.org>

BUGS

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.

SUPPORT

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:

ACKNOWLEDGEMENTS

COPYRIGHT & LICENSE

Copyright 2009-2010 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.