1
1
# redis-rb [ ![ Build Status] [ travis-image ]] [ travis-link ] [ ![ Inline docs] [ inchpages-image ]] [ inchpages-link ]
2
2
3
- [ travis-image ] : https://secure.travis-ci.org/redis/redis-rb.svg?branch=master
4
- [ travis-link ] : http://travis-ci.org/redis/redis-rb
5
- [ travis-home ] : http://travis-ci.org/
6
- [ inchpages-image ] : http://inch-ci.org/github/redis/redis-rb.svg
7
- [ inchpages-link ] : http://inch-ci.org/github/redis/redis-rb
3
+ A Ruby client that tries to match [ Redis] [ redis-home ] ' API one-to-one, while still
4
+ providing an idiomatic interface.
8
5
9
- A Ruby client library for [ Redis] [ redis-home ] .
10
-
11
- [ redis-home ] : http://redis.io
12
-
13
- A Ruby client that tries to match Redis' API one-to-one, while still
14
- providing an idiomatic interface. It features thread-safety, client-side
15
- sharding, pipelining, and an obsession for performance.
16
-
17
- ## Upgrading from 2.x to 3.0
18
-
19
- Please refer to the [ CHANGELOG] [ changelog-3.0.0 ] for a summary of the
20
- most important changes, as well as a full list of changes.
21
-
22
- [ changelog-3.0.0 ] : https://github.com/redis/redis-rb/blob/master/CHANGELOG.md#300
23
6
24
7
## Getting started
25
8
26
- To install ** redis-rb** , run the following command:
27
-
28
- ```
29
- gem install redis
30
- ```
31
-
32
- Or if you are using ** bundler** , add
9
+ Install with:
33
10
34
11
```
35
- gem 'redis', '~>3.2'
12
+ $ gem install redis
36
13
```
37
14
38
- to your ` Gemfile ` , and run ` bundle install `
39
-
40
- As of version 2.0 this client only targets Redis version 2.0 and higher.
41
- You can use an older version of this client if you need to interface
42
- with a Redis instance older than 2.0, but this is no longer supported.
43
-
44
15
You can connect to Redis by instantiating the ` Redis ` class:
45
16
46
17
``` ruby
@@ -54,40 +25,36 @@ listening on `localhost`, port 6379. If you need to connect to a remote
54
25
server or a different port, try:
55
26
56
27
``` ruby
57
- redis = Redis .new (: host => " 10.0.1.1" , : port => 6380 , :db => 15 )
28
+ redis = Redis .new (host: " 10.0.1.1" , port: 6380 , db: 15 )
58
29
```
59
30
60
31
You can also specify connection options as a [ ` redis:// ` URL] [ redis-url ] :
61
32
62
33
``` ruby
63
- redis
= Redis .
new (
: url => " redis://:[email protected] :6380/15" )
34
+ redis
= Redis .
new (
url: " redis://:[email protected] :6380/15" )
64
35
```
65
36
66
- [ redis-url ] : http://www.iana.org/assignments/uri-schemes/prov/redis
67
-
68
37
By default, the client will try to read the ` REDIS_URL ` environment variable
69
38
and use that as URL to connect to. The above statement is therefore equivalent
70
39
to setting this environment variable and calling ` Redis.new ` without arguments.
71
40
72
41
To connect to Redis listening on a Unix socket, try:
73
42
74
43
``` ruby
75
- redis = Redis .new (: path => " /tmp/redis.sock" )
44
+ redis = Redis .new (path: " /tmp/redis.sock" )
76
45
```
77
46
78
47
To connect to a password protected Redis instance, use:
79
48
80
49
``` ruby
81
- redis = Redis .new (: password => " mysecret" )
50
+ redis = Redis .new (password: " mysecret" )
82
51
```
83
52
84
53
The Redis class exports methods that are named identical to the commands
85
54
they execute. The arguments these methods accept are often identical to
86
55
the arguments specified on the [ Redis website] [ redis-commands ] . For
87
56
instance, the ` SET ` and ` GET ` commands can be called like this:
88
57
89
- [ redis-commands ] : http://redis.io/commands
90
-
91
58
``` ruby
92
59
redis.set(" mykey" , " hello world" )
93
60
# => "OK"
@@ -96,24 +63,22 @@ redis.get("mykey")
96
63
# => "hello world"
97
64
```
98
65
99
- All commands, their arguments and return values are documented, and
100
- available on [ rdoc.info] [ rdoc ] .
101
-
102
- [ rdoc ] : http://rdoc.info/github/redis/redis-rb/
66
+ All commands, their arguments, and return values are documented and
67
+ available on [ RubyDoc.info] [ rubydoc ] .
103
68
104
69
## Sentinel support
105
70
106
- The client is able to perform automatic failovers by using [ Redis
71
+ The client is able to perform automatic failover by using [ Redis
107
72
Sentinel] ( http://redis.io/topics/sentinel ) . Make sure to run Redis 2.8+
108
73
if you want to use this feature.
109
74
110
75
To connect using Sentinel, use:
111
76
112
77
``` ruby
113
- SENTINELS = [{: host => " 127.0.0.1" , : port => 26380 },
114
- {: host => " 127.0.0.1" , : port => 26381 }]
78
+ SENTINELS = [{ host: " 127.0.0.1" , port: 26380 },
79
+ { host: " 127.0.0.1" , port: 26381 }]
115
80
116
- redis = Redis .new (: url => " redis://mymaster" , : sentinels => SENTINELS , : role => :master )
81
+ redis = Redis .new (url: " redis://mymaster" , sentinels: SENTINELS , role: :master )
117
82
```
118
83
119
84
* The master name identifies a group of Redis instances composed of a master
@@ -374,37 +339,28 @@ redis = Redis.new(:driver => :synchrony)
374
339
375
340
## Testing
376
341
377
- This library is tested using [ Travis] [ travis-home ] , where it is tested
378
- against the following interpreters and drivers:
379
-
380
- * MRI 1.8.7 (drivers: ruby, hiredis)
381
- * MRI 1.9.3 (drivers: ruby, hiredis, synchrony)
382
- * MRI 2.0 (drivers: ruby, hiredis, synchrony)
383
- * MRI 2.1 (drivers: ruby, hiredis, synchrony)
384
- * MRI 2.2 (drivers: ruby, hiredis, synchrony)
385
- * MRI 2.3 (drivers: ruby, hiredis, synchrony)
386
- * JRuby 1.7 (1.8 mode) (drivers: ruby)
387
- * JRuby 1.7 (1.9 mode) (drivers: ruby)
342
+ This library is tested against recent Ruby and Redis versions.
343
+ Check [ Travis] [ travis-link ] for the exact versions supported.
388
344
389
345
## Contributors
390
346
391
- (ordered chronologically with more than 5 commits, see ` git shortlog -sn ` for
392
- all contributors)
393
-
394
- * Ezra Zygmuntowicz
395
- * Taylor Weibley
396
- * Matthew Clark
397
- * Brian McKinney
398
- * Luca Guidi
399
- * Salvatore Sanfilippo
400
- * Chris Wanstrath
401
- * Damian Janowski
402
- * Michel Martens
403
- * Nick Quaranto
404
- * Pieter Noordhuis
405
- * Ilya Grigorik
347
+ Several people contributed to redis-rb, but we would like to especially
348
+ mention Ezra Zygmuntowicz. Ezra introduced the Ruby community to many
349
+ new cool technologies, like Redis. He wrote the first version of this
350
+ client and evangelized Redis in Rubyland. Thank you, Ezra.
406
351
407
352
## Contributing
408
353
409
354
[ Fork the project] ( https://github.com/redis/redis-rb ) and send pull
410
355
requests. You can also ask for help at ` #redis-rb ` on Freenode.
356
+
357
+
358
+ [ inchpages-image ] : https://inch-ci.org/github/redis/redis-rb.svg
359
+ [ inchpages-link ] : https://inch-ci.org/github/redis/redis-rb
360
+ [ redis-commands ] : https://redis.io/commands
361
+ [ redis-home ] : https://redis.io
362
+ [ redis-url ] : http://www.iana.org/assignments/uri-schemes/prov/redis
363
+ [ travis-home ] : https://travis-ci.org/
364
+ [ travis-image ] : https://secure.travis-ci.org/redis/redis-rb.svg?branch=master
365
+ [ travis-link ] : https://travis-ci.org/redis/redis-rb
366
+ [ rubydoc ] : https://www.rubydoc.info/gems/redis
0 commit comments