redis 2.1.1 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. data/.gitignore +8 -0
  2. data/CHANGELOG.md +34 -0
  3. data/README.md +190 -0
  4. data/Rakefile +194 -79
  5. data/benchmarking/logging.rb +62 -0
  6. data/benchmarking/pipeline.rb +51 -0
  7. data/benchmarking/speed.rb +21 -0
  8. data/benchmarking/suite.rb +24 -0
  9. data/benchmarking/thread_safety.rb +38 -0
  10. data/benchmarking/worker.rb +71 -0
  11. data/examples/basic.rb +15 -0
  12. data/examples/dist_redis.rb +43 -0
  13. data/examples/incr-decr.rb +17 -0
  14. data/examples/list.rb +26 -0
  15. data/examples/pubsub.rb +31 -0
  16. data/examples/sets.rb +36 -0
  17. data/examples/unicorn/config.ru +3 -0
  18. data/examples/unicorn/unicorn.rb +20 -0
  19. data/lib/redis.rb +612 -156
  20. data/lib/redis/client.rb +98 -57
  21. data/lib/redis/connection.rb +9 -134
  22. data/lib/redis/connection/command_helper.rb +45 -0
  23. data/lib/redis/connection/hiredis.rb +49 -0
  24. data/lib/redis/connection/registry.rb +12 -0
  25. data/lib/redis/connection/ruby.rb +131 -0
  26. data/lib/redis/connection/synchrony.rb +125 -0
  27. data/lib/redis/distributed.rb +161 -5
  28. data/lib/redis/pipeline.rb +6 -0
  29. data/lib/redis/version.rb +3 -0
  30. data/redis.gemspec +24 -0
  31. data/test/commands_on_hashes_test.rb +32 -0
  32. data/test/commands_on_lists_test.rb +60 -0
  33. data/test/commands_on_sets_test.rb +78 -0
  34. data/test/commands_on_sorted_sets_test.rb +109 -0
  35. data/test/commands_on_strings_test.rb +80 -0
  36. data/test/commands_on_value_types_test.rb +88 -0
  37. data/test/connection_handling_test.rb +87 -0
  38. data/test/db/.gitignore +1 -0
  39. data/test/distributed_blocking_commands_test.rb +53 -0
  40. data/test/distributed_commands_on_hashes_test.rb +12 -0
  41. data/test/distributed_commands_on_lists_test.rb +24 -0
  42. data/test/distributed_commands_on_sets_test.rb +85 -0
  43. data/test/distributed_commands_on_strings_test.rb +50 -0
  44. data/test/distributed_commands_on_value_types_test.rb +73 -0
  45. data/test/distributed_commands_requiring_clustering_test.rb +148 -0
  46. data/test/distributed_connection_handling_test.rb +25 -0
  47. data/test/distributed_internals_test.rb +18 -0
  48. data/test/distributed_key_tags_test.rb +53 -0
  49. data/test/distributed_persistence_control_commands_test.rb +24 -0
  50. data/test/distributed_publish_subscribe_test.rb +101 -0
  51. data/test/distributed_remote_server_control_commands_test.rb +31 -0
  52. data/test/distributed_sorting_test.rb +21 -0
  53. data/test/distributed_test.rb +60 -0
  54. data/test/distributed_transactions_test.rb +34 -0
  55. data/test/encoding_test.rb +16 -0
  56. data/test/error_replies_test.rb +53 -0
  57. data/test/helper.rb +145 -0
  58. data/test/internals_test.rb +157 -0
  59. data/test/lint/hashes.rb +114 -0
  60. data/test/lint/internals.rb +41 -0
  61. data/test/lint/lists.rb +93 -0
  62. data/test/lint/sets.rb +66 -0
  63. data/test/lint/sorted_sets.rb +167 -0
  64. data/test/lint/strings.rb +137 -0
  65. data/test/lint/value_types.rb +84 -0
  66. data/test/persistence_control_commands_test.rb +22 -0
  67. data/test/pipelining_commands_test.rb +123 -0
  68. data/test/publish_subscribe_test.rb +158 -0
  69. data/test/redis_mock.rb +80 -0
  70. data/test/remote_server_control_commands_test.rb +63 -0
  71. data/test/sorting_test.rb +44 -0
  72. data/test/synchrony_driver.rb +57 -0
  73. data/test/test.conf +8 -0
  74. data/test/thread_safety_test.rb +30 -0
  75. data/test/transactions_test.rb +100 -0
  76. data/test/unknown_commands_test.rb +14 -0
  77. data/test/url_param_test.rb +60 -0
  78. metadata +128 -19
  79. data/README.markdown +0 -129
@@ -1,129 +0,0 @@
1
- # redis-rb
2
-
3
- A Ruby client library for the [Redis](http://code.google.com/p/redis) key-value store.
4
-
5
- ## A note about versions
6
-
7
- Versions *1.0.x* target all versions of Redis. You have to use this one if you are using Redis < 1.2.
8
-
9
- Version *2.0* is a big refactoring of the previous version and makes little effort to be
10
- backwards-compatible when it shouldn't. It does not support Redis' original protocol, favoring the
11
- new, binary-safe one. You should be using this version if you're running Redis 1.2+.
12
-
13
- ## Information about Redis
14
-
15
- Redis is a key-value store with some interesting features:
16
-
17
- 1. It's fast.
18
- 2. Keys are strings but values are typed. Currently Redis supports strings, lists, sets, sorted sets and hashes. [Atomic operations](http://code.google.com/p/redis/wiki/CommandReference) can be done on all of these types.
19
-
20
- See [the Redis homepage](http://code.google.com/p/redis/wiki/README) for more information.
21
-
22
- ## Getting started
23
-
24
- You can connect to Redis by instantiating the `Redis` class:
25
-
26
- require "redis"
27
-
28
- redis = Redis.new
29
-
30
- This assumes Redis was started with default values listening on `localhost`, port 6379. If you need to connect to a remote server or a different port, try:
31
-
32
- redis = Redis.new(:host => "10.0.1.1", :port => 6380)
33
-
34
- Once connected, you can start running commands against Redis:
35
-
36
- >> redis.set "foo", "bar"
37
- => "OK"
38
-
39
- >> redis.get "foo"
40
- => "bar"
41
-
42
- >> redis.sadd "users", "albert"
43
- => true
44
-
45
- >> redis.sadd "users", "bernard"
46
- => true
47
-
48
- >> redis.sadd "users", "charles"
49
- => true
50
-
51
- How many users?
52
-
53
- >> redis.scard "users"
54
- => 3
55
-
56
- Is `albert` a user?
57
-
58
- >> redis.sismember "users", "albert"
59
- => true
60
-
61
- Is `isabel` a user?
62
-
63
- >> redis.sismember "users", "isabel"
64
- => false
65
-
66
- Handle groups:
67
-
68
- >> redis.sadd "admins", "albert"
69
- => true
70
-
71
- >> redis.sadd "admins", "isabel"
72
- => true
73
-
74
- Users who are also admins:
75
-
76
- >> redis.sinter "users", "admins"
77
- => ["albert"]
78
-
79
- Users who are not admins:
80
-
81
- >> redis.sdiff "users", "admins"
82
- => ["bernard", "charles"]
83
-
84
- Admins who are not users:
85
-
86
- >> redis.sdiff "admins", "users"
87
- => ["isabel"]
88
-
89
- All users and admins:
90
-
91
- >> redis.sunion "admins", "users"
92
- => ["albert", "bernard", "charles", "isabel"]
93
-
94
-
95
- ## Storing objects
96
-
97
- Redis only stores strings as values. If you want to store an object inside a key, you can use a serialization/deseralization mechanism like JSON:
98
-
99
- >> redis.set "foo", [1, 2, 3].to_json
100
- => OK
101
-
102
- >> JSON.parse(redis.get("foo"))
103
- => [1, 2, 3]
104
-
105
- ## Executing multiple commands atomically
106
-
107
- You can use `MULTI/EXEC` to run arbitrary commands in an atomic fashion:
108
-
109
- redis.multi do
110
- redis.set "foo", "bar"
111
- redis.incr "baz"
112
- end
113
-
114
- ## Multithreaded Operation
115
-
116
- To use redis safely in a multithreaded environment, be sure to initialize the client with :thread_safe=>true
117
-
118
- Redis.new(:thread_safe=>true)
119
-
120
- See the tests and benchmarks for examples.
121
-
122
-
123
- ## More info
124
-
125
- Check the [Redis Command Reference](http://code.google.com/p/redis/wiki/CommandReference) or check the tests to find out how to use this client.
126
-
127
- ## Contributing
128
-
129
- [Fork the project](http://github.com/ezmobius/redis-rb) and send pull requests. You can also ask for help at `#redis-rb` on Freenode.