discourse-redis 3.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +16 -0
  3. data/.travis.yml +59 -0
  4. data/.travis/Gemfile +11 -0
  5. data/.yardopts +3 -0
  6. data/CHANGELOG.md +349 -0
  7. data/Gemfile +4 -0
  8. data/LICENSE +20 -0
  9. data/README.md +328 -0
  10. data/Rakefile +87 -0
  11. data/benchmarking/logging.rb +71 -0
  12. data/benchmarking/pipeline.rb +51 -0
  13. data/benchmarking/speed.rb +21 -0
  14. data/benchmarking/suite.rb +24 -0
  15. data/benchmarking/worker.rb +71 -0
  16. data/examples/basic.rb +15 -0
  17. data/examples/consistency.rb +114 -0
  18. data/examples/dist_redis.rb +43 -0
  19. data/examples/incr-decr.rb +17 -0
  20. data/examples/list.rb +26 -0
  21. data/examples/pubsub.rb +37 -0
  22. data/examples/sentinel.rb +41 -0
  23. data/examples/sentinel/start +49 -0
  24. data/examples/sets.rb +36 -0
  25. data/examples/unicorn/config.ru +3 -0
  26. data/examples/unicorn/unicorn.rb +20 -0
  27. data/lib/redis.rb +2731 -0
  28. data/lib/redis/client.rb +575 -0
  29. data/lib/redis/connection.rb +9 -0
  30. data/lib/redis/connection/command_helper.rb +44 -0
  31. data/lib/redis/connection/hiredis.rb +64 -0
  32. data/lib/redis/connection/registry.rb +12 -0
  33. data/lib/redis/connection/ruby.rb +322 -0
  34. data/lib/redis/connection/synchrony.rb +124 -0
  35. data/lib/redis/distributed.rb +873 -0
  36. data/lib/redis/errors.rb +40 -0
  37. data/lib/redis/hash_ring.rb +132 -0
  38. data/lib/redis/pipeline.rb +141 -0
  39. data/lib/redis/subscribe.rb +83 -0
  40. data/lib/redis/version.rb +3 -0
  41. data/redis.gemspec +34 -0
  42. data/test/bitpos_test.rb +69 -0
  43. data/test/blocking_commands_test.rb +42 -0
  44. data/test/command_map_test.rb +30 -0
  45. data/test/commands_on_hashes_test.rb +21 -0
  46. data/test/commands_on_hyper_log_log_test.rb +21 -0
  47. data/test/commands_on_lists_test.rb +20 -0
  48. data/test/commands_on_sets_test.rb +77 -0
  49. data/test/commands_on_sorted_sets_test.rb +137 -0
  50. data/test/commands_on_strings_test.rb +101 -0
  51. data/test/commands_on_value_types_test.rb +133 -0
  52. data/test/connection_handling_test.rb +250 -0
  53. data/test/distributed_blocking_commands_test.rb +46 -0
  54. data/test/distributed_commands_on_hashes_test.rb +10 -0
  55. data/test/distributed_commands_on_hyper_log_log_test.rb +33 -0
  56. data/test/distributed_commands_on_lists_test.rb +22 -0
  57. data/test/distributed_commands_on_sets_test.rb +83 -0
  58. data/test/distributed_commands_on_sorted_sets_test.rb +18 -0
  59. data/test/distributed_commands_on_strings_test.rb +59 -0
  60. data/test/distributed_commands_on_value_types_test.rb +95 -0
  61. data/test/distributed_commands_requiring_clustering_test.rb +164 -0
  62. data/test/distributed_connection_handling_test.rb +23 -0
  63. data/test/distributed_internals_test.rb +79 -0
  64. data/test/distributed_key_tags_test.rb +52 -0
  65. data/test/distributed_persistence_control_commands_test.rb +26 -0
  66. data/test/distributed_publish_subscribe_test.rb +92 -0
  67. data/test/distributed_remote_server_control_commands_test.rb +66 -0
  68. data/test/distributed_scripting_test.rb +102 -0
  69. data/test/distributed_sorting_test.rb +20 -0
  70. data/test/distributed_test.rb +58 -0
  71. data/test/distributed_transactions_test.rb +32 -0
  72. data/test/encoding_test.rb +18 -0
  73. data/test/error_replies_test.rb +59 -0
  74. data/test/fork_safety_test.rb +65 -0
  75. data/test/helper.rb +232 -0
  76. data/test/helper_test.rb +24 -0
  77. data/test/internals_test.rb +437 -0
  78. data/test/lint/blocking_commands.rb +150 -0
  79. data/test/lint/hashes.rb +162 -0
  80. data/test/lint/hyper_log_log.rb +60 -0
  81. data/test/lint/lists.rb +143 -0
  82. data/test/lint/sets.rb +125 -0
  83. data/test/lint/sorted_sets.rb +316 -0
  84. data/test/lint/strings.rb +260 -0
  85. data/test/lint/value_types.rb +122 -0
  86. data/test/persistence_control_commands_test.rb +26 -0
  87. data/test/pipelining_commands_test.rb +242 -0
  88. data/test/publish_subscribe_test.rb +254 -0
  89. data/test/remote_server_control_commands_test.rb +118 -0
  90. data/test/scanning_test.rb +413 -0
  91. data/test/scripting_test.rb +78 -0
  92. data/test/sentinel_command_test.rb +80 -0
  93. data/test/sentinel_test.rb +255 -0
  94. data/test/sorting_test.rb +59 -0
  95. data/test/support/connection/hiredis.rb +1 -0
  96. data/test/support/connection/ruby.rb +1 -0
  97. data/test/support/connection/synchrony.rb +17 -0
  98. data/test/support/redis_mock.rb +119 -0
  99. data/test/support/wire/synchrony.rb +24 -0
  100. data/test/support/wire/thread.rb +5 -0
  101. data/test/synchrony_driver.rb +88 -0
  102. data/test/test.conf.erb +9 -0
  103. data/test/thread_safety_test.rb +32 -0
  104. data/test/transactions_test.rb +264 -0
  105. data/test/unknown_commands_test.rb +14 -0
  106. data/test/url_param_test.rb +138 -0
  107. metadata +182 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d53ddafe2f44e19177a19e173869a6406d93c0ad
4
+ data.tar.gz: df789bbf5e2f782dfce868b0c8c4ec655caffe58
5
+ SHA512:
6
+ metadata.gz: 918dac436bf6adaae7eb6025ab531b84bf108c1641791750fa039ca00b86890e807c5f391969967a49895cdd8ff86d6930e6526df6189521787a44fef9e5803d
7
+ data.tar.gz: 0c8f95084121c9fc852d67880d3492708c651124acb165ff938f401cac4cb9c9920af9e5f6b67e196356c61a33dcdac8ca376211c7801208d8973e64bbd6eb57
@@ -0,0 +1,16 @@
1
+ *.rdb
2
+ *.swp
3
+ Gemfile.lock
4
+ *.gem
5
+ /tmp/
6
+ /.idea
7
+ /.yardoc
8
+ /coverage/*
9
+ /doc/
10
+ /examples/sentinel/sentinel.conf
11
+ /nohup.out
12
+ /pkg/*
13
+ /rdsrv
14
+ /redis/*
15
+ /test/db
16
+ /test/test.conf
@@ -0,0 +1,59 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 1.8.7
5
+ - 1.9.3
6
+ - 2.0
7
+ - 2.1
8
+ - 2.2
9
+ - jruby-18mode
10
+ - jruby-19mode
11
+ - rbx-2
12
+
13
+ gemfile: ".travis/Gemfile"
14
+
15
+ sudo: false
16
+
17
+ env:
18
+ global:
19
+ - VERBOSE=true
20
+ - TIMEOUT=1
21
+ matrix:
22
+ - conn=ruby REDIS_BRANCH=2.8
23
+ - conn=hiredis REDIS_BRANCH=2.8
24
+ - conn=synchrony REDIS_BRANCH=2.8
25
+ - conn=ruby REDIS_BRANCH=unstable
26
+
27
+ branches:
28
+ only:
29
+ - master
30
+
31
+ matrix:
32
+ exclude:
33
+ # hiredis
34
+ - rvm: jruby-18mode
35
+ gemfile: .travis/Gemfile
36
+ env: conn=hiredis REDIS_BRANCH=2.8
37
+ - rvm: jruby-19mode
38
+ gemfile: .travis/Gemfile
39
+ env: conn=hiredis REDIS_BRANCH=2.8
40
+
41
+ # synchrony
42
+ - rvm: 1.8.7
43
+ gemfile: .travis/Gemfile
44
+ env: conn=synchrony REDIS_BRANCH=2.8
45
+ - rvm: jruby-18mode
46
+ gemfile: .travis/Gemfile
47
+ env: conn=synchrony REDIS_BRANCH=2.8
48
+ - rvm: jruby-19mode
49
+ gemfile: .travis/Gemfile
50
+ env: conn=synchrony REDIS_BRANCH=2.8
51
+ allow_failures:
52
+ - rvm: rbx-2
53
+
54
+ notifications:
55
+ irc:
56
+ - irc.freenode.net#redis-rb
57
+ email:
58
+ - damian.janowski@gmail.com
59
+ - pcnoordhuis@gmail.com
@@ -0,0 +1,11 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec :path => "../"
4
+
5
+ case ENV["conn"]
6
+ when "hiredis"
7
+ gem "hiredis"
8
+ when "synchrony"
9
+ gem "hiredis"
10
+ gem "em-synchrony"
11
+ end
@@ -0,0 +1,3 @@
1
+ --exclude redis/connection
2
+ --exclude redis/compat
3
+ --markup markdown
@@ -0,0 +1,349 @@
1
+ # 4.x (unreleased)
2
+
3
+ ## Planned breaking changes:
4
+ * `Redis#client` will no longer expose the underlying `Redis::Client`;
5
+ it has not yet been determined how 4.0 will expose the underlying
6
+ functionality, but we will make every attempt to provide a final minor
7
+ release of 3.x that provides the new interfaces in order to facilitate
8
+ a smooth transition.
9
+
10
+ * Ruby 1.8.7 (and the 1.8 modes of JRuby and Rubinius) will no longer be
11
+ supported; 1.8.x entered end-of-life in June of 2012 and stopped receiving
12
+ security updates in June of 2013; continuing to support it would prevent
13
+ the use of newer features of Ruby.
14
+
15
+ # 3.2.2
16
+
17
+ * Added support for `ZADD` options `NX`, `XX`, `CH`, `INCR`. See #547.
18
+
19
+ * Added support for sentinel commands. See #556.
20
+
21
+ * New `:id` option allows you to identify the client against Redis. See #510.
22
+
23
+ * `Redis::Distributed` will raise when adding two nodes with the same ID.
24
+ See #354.
25
+
26
+ # 3.2.1
27
+
28
+ * Added support for `PUBSUB` command.
29
+
30
+ * More low-level socket errors are now raised as `CannotConnectError`.
31
+
32
+ * Added `:connect_timeout` option.
33
+
34
+ * Added support for `:limit` option for `ZREVRANGEBYLEX`.
35
+
36
+ * Fixed an issue where connections become inconsistent when using Ruby's
37
+ Timeout module outside of the client (see #501, #502).
38
+
39
+ * Added `Redis#disconnect!` as a public-API way of disconnecting the client
40
+ (without needing to use `QUIT`). See #506.
41
+
42
+ * Fixed Sentinel support with Hiredis.
43
+
44
+ * Fixed Sentinel support when using authentication and databases.
45
+
46
+ * Improved resilience when trying to contact sentinels.
47
+
48
+ # 3.2.0
49
+
50
+ * Redis Sentinel support.
51
+
52
+ # 3.1.0
53
+
54
+ * Added debug log sanitization (#428).
55
+
56
+ * Added support for HyperLogLog commands (Redis 2.8.9, #432).
57
+
58
+ * Added support for `BITPOS` command (Redis 2.9.11, #412).
59
+
60
+ * The client will now automatically reconnect after a fork (#414).
61
+
62
+ * If you want to disable the fork-safety check and prefer to share the
63
+ connection across child processes, you can now pass the `inherit_socket`
64
+ option (#409).
65
+
66
+ * If you want the client to attempt to reconnect more than once, you can now
67
+ pass the `reconnect_attempts` option (#347)
68
+
69
+ # 3.0.7
70
+
71
+ * Added method `Redis#dup` to duplicate a Redis connection.
72
+
73
+ * IPv6 support.
74
+
75
+ # 3.0.6
76
+
77
+ * Added support for `SCAN` and variants.
78
+
79
+ # 3.0.5
80
+
81
+ * Fix calling #select from a pipeline (#309).
82
+
83
+ * Added method `Redis#connected?`.
84
+
85
+ * Added support for `MIGRATE` (Redis 2.6).
86
+
87
+ * Support extended SET command (#343, thanks to @benubois).
88
+
89
+ # 3.0.4
90
+
91
+ * Ensure #watch without a block returns "OK" (#332).
92
+
93
+ * Make futures identifiable (#330).
94
+
95
+ * Fix an issue preventing STORE in a SORT with multiple GETs (#328).
96
+
97
+ # 3.0.3
98
+
99
+ * Blocking list commands (`BLPOP`, `BRPOP`, `BRPOPLPUSH`) use a socket
100
+ timeout equal to the sum of the command's timeout and the Redis
101
+ client's timeout, instead of disabling socket timeout altogether.
102
+
103
+ * Ruby 2.0 compatibility.
104
+
105
+ * Added support for `DUMP` and `RESTORE` (Redis 2.6).
106
+
107
+ * Added support for `BITCOUNT` and `BITOP` (Redis 2.6).
108
+
109
+ * Call `#to_s` on value argument for `SET`, `SETEX`, `PSETEX`, `GETSET`,
110
+ `SETNX`, and `SETRANGE`.
111
+
112
+ # 3.0.2
113
+
114
+ * Unescape CGI escaped password in URL.
115
+
116
+ * Fix test to check availability of `UNIXSocket`.
117
+
118
+ * Fix handling of score = +/- infinity for sorted set commands.
119
+
120
+ * Replace array splats with concatenation where possible.
121
+
122
+ * Raise if `EXEC` returns an error.
123
+
124
+ * Passing a nil value in options hash no longer overwrites the default.
125
+
126
+ * Allow string keys in options hash passed to `Redis.new` or
127
+ `Redis.connect`.
128
+
129
+ * Fix uncaught error triggering unrelated error (synchrony driver).
130
+
131
+ See f7ffd5f1a628029691084de69e5b46699bb8b96d and #248.
132
+
133
+ # 3.0.1
134
+
135
+ * Fix reconnect logic not kicking in on a write error.
136
+
137
+ See 427dbd52928af452f35aa0a57b621bee56cdcb18 and #238.
138
+
139
+ # 3.0.0
140
+
141
+ ### Upgrading from 2.x to 3.0
142
+
143
+ The following items are the most important changes to review when
144
+ upgrading from redis-rb 2.x. A full list of changes can be found below.
145
+
146
+ * The methods for the following commands have changed the arguments they
147
+ take, their return value, or both.
148
+
149
+ * `BLPOP`, `BRPOP`, `BRPOPLPUSH`
150
+ * `SORT`
151
+ * `MSETNX`
152
+ * `ZRANGE`, `ZREVRANGE`, `ZRANGEBYSCORE`, `ZREVRANGEBYSCORE`
153
+ * `ZINCRBY`, `ZSCORE`
154
+
155
+ * The return value from `#pipelined` and `#multi` no longer contains
156
+ unprocessed replies, but the same replies that would be returned if
157
+ the command had not been executed in these blocks.
158
+
159
+ * The client raises custom errors on connection errors, instead of
160
+ `RuntimeError` and errors in the `Errno` family.
161
+
162
+ ### Changes
163
+
164
+ * Added support for scripting commands (Redis 2.6).
165
+
166
+ Scripts can be executed using `#eval` and `#evalsha`. Both can
167
+ commands can either take two arrays to specify `KEYS` and `ARGV`, or
168
+ take a hash containing `:keys` and `:argv` to specify `KEYS` and
169
+ `ARGV`.
170
+
171
+ ```ruby
172
+ redis.eval("return ARGV[1] * ARGV[2]", :argv => [2, 3])
173
+ # => 6
174
+ ```
175
+
176
+ Subcommands of the `SCRIPT` command can be executed via the
177
+ `#script` method.
178
+
179
+ For example:
180
+
181
+ ```ruby
182
+ redis.script(:load, "return ARGV[1] * ARGV[2]")
183
+ # => "58db5d365a1922f32e7aa717722141ea9c2b0cf3"
184
+ redis.script(:exists, "58db5d365a1922f32e7aa717722141ea9c2b0cf3")
185
+ # => true
186
+ redis.script(:flush)
187
+ # => "OK"
188
+ ```
189
+
190
+ * The repository now lives at [https://github.com/redis/redis-rb](https://github.com/redis/redis-rb).
191
+ Thanks, Ezra!
192
+
193
+ * Added support for `PEXPIRE`, `PEXPIREAT`, `PTTL`, `PSETEX`,
194
+ `INCRYBYFLOAT`, `HINCRYBYFLOAT` and `TIME` (Redis 2.6).
195
+
196
+ * `Redis.current` is now thread unsafe, because the client itself is thread safe.
197
+
198
+ In the future you'll be able to do something like:
199
+
200
+ ```ruby
201
+ Redis.current = Redis::Pool.connect
202
+ ```
203
+
204
+ This makes `Redis.current` actually usable in multi-threaded environments,
205
+ while not affecting those running a single thread.
206
+
207
+ * Change API for `BLPOP`, `BRPOP` and `BRPOPLPUSH`.
208
+
209
+ Both `BLPOP` and `BRPOP` now take a single argument equal to a
210
+ string key, or an array with string keys, followed by an optional
211
+ hash with a `:timeout` key. When not specified, the timeout defaults
212
+ to `0` to not time out.
213
+
214
+ ```ruby
215
+ redis.blpop(["list1", "list2"], :timeout => 1.0)
216
+ ```
217
+
218
+ `BRPOPLPUSH` also takes an optional hash with a `:timeout` key as
219
+ last argument for consistency. When not specified, the timeout
220
+ defaults to `0` to not time out.
221
+
222
+ ```ruby
223
+ redis.brpoplpush("some_list", "another_list", :timeout => 1.0)
224
+ ```
225
+
226
+ * When `SORT` is passed multiple key patterns to get via the `:get`
227
+ option, it now returns an array per result element, holding all `GET`
228
+ substitutions.
229
+
230
+ * The `MSETNX` command now returns a boolean.
231
+
232
+ * The `ZRANGE`, `ZREVRANGE`, `ZRANGEBYSCORE` and `ZREVRANGEBYSCORE` commands
233
+ now return an array containing `[String, Float]` pairs when
234
+ `:with_scores => true` is passed.
235
+
236
+ For example:
237
+
238
+ ```ruby
239
+ redis.zrange("zset", 0, -1, :with_scores => true)
240
+ # => [["foo", 1.0], ["bar", 2.0]]
241
+ ```
242
+
243
+ * The `ZINCRBY` and `ZSCORE` commands now return a `Float` score instead
244
+ of a string holding a representation of the score.
245
+
246
+ * The client now raises custom exceptions where it makes sense.
247
+
248
+ If by any chance you were rescuing low-level exceptions (`Errno::*`),
249
+ you should now rescue as follows:
250
+
251
+ Errno::ECONNRESET -> Redis::ConnectionError
252
+ Errno::EPIPE -> Redis::ConnectionError
253
+ Errno::ECONNABORTED -> Redis::ConnectionError
254
+ Errno::EBADF -> Redis::ConnectionError
255
+ Errno::EINVAL -> Redis::ConnectionError
256
+ Errno::EAGAIN -> Redis::TimeoutError
257
+ Errno::ECONNREFUSED -> Redis::CannotConnectError
258
+
259
+ * Always raise exceptions originating from erroneous command invocation
260
+ inside pipelines and MULTI/EXEC blocks.
261
+
262
+ The old behavior (swallowing exceptions) could cause application bugs
263
+ to go unnoticed.
264
+
265
+ * Implement futures for assigning values inside pipelines and MULTI/EXEC
266
+ blocks. Futures are assigned their value after the pipeline or
267
+ MULTI/EXEC block has executed.
268
+
269
+ ```ruby
270
+ $redis.pipelined do
271
+ @future = $redis.get "key"
272
+ end
273
+
274
+ puts @future.value
275
+ ```
276
+
277
+ * Ruby 1.8.6 is officially not supported.
278
+
279
+ * Support `ZCOUNT` in `Redis::Distributed` (Michael Dungan).
280
+
281
+ * Pipelined commands now return the same replies as when called outside
282
+ a pipeline.
283
+
284
+ In the past, pipelined replies were returned without post-processing.
285
+
286
+ * Support `SLOWLOG` command (Michael Bernstein).
287
+
288
+ * Calling `SHUTDOWN` effectively disconnects the client (Stefan Kaes).
289
+
290
+ * Basic support for mapping commands so that they can be renamed on the
291
+ server.
292
+
293
+ * Connecting using a URL now checks that a host is given.
294
+
295
+ It's just a small sanity check, cf. #126
296
+
297
+ * Support variadic commands introduced in Redis 2.4.
298
+
299
+ # 2.2.2
300
+
301
+ * Added method `Redis::Distributed#hsetnx`.
302
+
303
+ # 2.2.1
304
+
305
+ * Internal API: Client#call and family are now called with a single array
306
+ argument, since splatting a large number of arguments (100K+) results in a
307
+ stack overflow on 1.9.2.
308
+
309
+ * The `INFO` command can optionally take a subcommand. When the subcommand is
310
+ `COMMANDSTATS`, the client will properly format the returned statistics per
311
+ command. Subcommands for `INFO` are available since Redis v2.3.0 (unstable).
312
+
313
+ * Change `IO#syswrite` back to the buffered `IO#write` since some Rubies do
314
+ short writes for large (1MB+) buffers and some don't (see issue #108).
315
+
316
+ # 2.2.0
317
+
318
+ * Added method `Redis#without_reconnect` that ensures the client will not try
319
+ to reconnect when running the code inside the specified block.
320
+
321
+ * Thread-safe by default. Thread safety can be explicitly disabled by passing
322
+ `:thread_safe => false` as argument.
323
+
324
+ * Commands called inside a MULTI/EXEC no longer raise error replies, since a
325
+ successful EXEC means the commands inside the block were executed.
326
+
327
+ * MULTI/EXEC blocks are pipelined.
328
+
329
+ * Don't disconnect on error replies.
330
+
331
+ * Use `IO#syswrite` instead of `IO#write` because write buffering is not
332
+ necessary.
333
+
334
+ * Connect to a unix socket by passing the `:path` option as argument.
335
+
336
+ * The timeout value is coerced into a float, allowing sub-second timeouts.
337
+
338
+ * Accept both `:with_scores` _and_ `:withscores` as argument to sorted set
339
+ commands.
340
+
341
+ * Use [hiredis](https://github.com/pietern/hiredis-rb) (v0.3 or higher) by
342
+ requiring "redis/connection/hiredis".
343
+
344
+ * Use [em-synchrony](https://github.com/igrigorik/em-synchrony) by requiring
345
+ "redis/connection/synchrony".
346
+
347
+ # 2.1.1
348
+
349
+ See commit log.