The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Redis::hiredis - interact with Redis using the hiredis client.

SYNOPSIS

  use Redis::hiredis;
  my $redis = Redis::hiredis->new();
  $redis->connect('127.0.0.1', 6379);
  $redis->command('set foo bar');
  my $val = $redis->command('get foo');

  # to pipeline commands
  $redis->append_command('set abc 123');
  $redis->append_command('get abc');
  my $set_status = $redis->get_reply(); # 'OK'
  my $get_val = $redis->get_reply(); # 123

DESCRIPTION

Redis::hiredis is a simple wrapper around Salvatore Sanfilippo's hiredis C client that allows connecting and sending any command just like you would from a command line Redis client.

NOTE Versions >= 0.9.2 are not compatible with prior versions

METHODS

new()

Creates a new Redis::hiredis object.

connect( $hostname, $port )

$hostname is the hostname of the Redis server to connect to

$port is the port to connect on. Default 6379

command( $command )

$command is a string identical to what you would pass using the official redis cli

  'set foo bar'

command will return a scalar value which will either be an integer, string or an array ref (if multiple values are returned).

append_command( $command )

For performance reasons, it's sometimes useful to pipeline commands. When pipelining, muiltple commands are sent to the server at once and the results are read as they become available. hiredis supports this via append_command() and get_reply(). Commands passed to append_command() are buffered locally until the first call to get_reply() when all the commands are sent to the server at once. The results are then returned one at a time via calls to get_reply().

See the hiredis documentation for a more detailed explanation.

get_reply()

See append_command().

SEE ALSO

The Redis command reference can be found here: http://redis.io/commands

A discusion of pipelining can be found here: http://redis.io/topics/pipelining

Documentation on the hiredis client can be found here: http://github.com/antirez/hiredis