-
Notifications
You must be signed in to change notification settings - Fork 8
/
README
109 lines (79 loc) · 3.85 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
INSTALLATION
To install this module type the following:
perl Makefile.PL
make
make test
make install
Documentation is provided in the module and perldoc output is copied below:
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');
$redis−>command(["set", "foo", "bar baz"]); # values with spaces
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 and <= 0.9.2.4 are not compatible with prior
versions
METHODS
new([utf8 => 1], [host => "localhost"], [port => 6379], [path => "/tmp/redis.sock"])
Creates a new Redis::hiredis object.
If the host attribute is provided the "connect" method will
automatically be called.
If the path attribute is provided the "connect_unix" method will
automatically be called.
connect( $hostname, $port )
$hostname is the hostname of the Redis server to connect to
$port is the port to connect on. Default 6379
connect_unix( $path )
$path is the path to the unix socket
command( $command_and_args )
command( [ $command, $arg, ... ] )
command( $command, $arg, ... )
command supports multiple types of calls to be backwards compatible
and provide more convenient use. Examples of how to pass arguments
are:
$redis−>command('set foo bar');
$redis−>command(["set", "foo", "bar baz"]);
$redis−>command("set", "foo", "bar baz");
Note that if you have spaces in your values, you must use one of
the last 2 forms.
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().
Autoloaded Methods
Autoload is used to allow an interface like $redis−>set("foo", "bar").
The method name you provide will be passed blindly to Redis, so any
supported command should work.
Note that to use any autoloaded method, you must pass arguments as an
array, the string and array ref forms supported by command will not
work.
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:
<https://github.com/antirez/hiredis>
Redis::hiredis on github: <https://github.com/neophenix/redis−hiredis>