redis 4.0.0 → 5.0.0

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 (137) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +252 -1
  3. data/README.md +126 -88
  4. data/lib/redis/client.rb +79 -543
  5. data/lib/redis/commands/bitmaps.rb +66 -0
  6. data/lib/redis/commands/cluster.rb +28 -0
  7. data/lib/redis/commands/connection.rb +53 -0
  8. data/lib/redis/commands/geo.rb +84 -0
  9. data/lib/redis/commands/hashes.rb +254 -0
  10. data/lib/redis/commands/hyper_log_log.rb +37 -0
  11. data/lib/redis/commands/keys.rb +437 -0
  12. data/lib/redis/commands/lists.rb +285 -0
  13. data/lib/redis/commands/pubsub.rb +54 -0
  14. data/lib/redis/commands/scripting.rb +114 -0
  15. data/lib/redis/commands/server.rb +188 -0
  16. data/lib/redis/commands/sets.rb +214 -0
  17. data/lib/redis/commands/sorted_sets.rb +818 -0
  18. data/lib/redis/commands/streams.rb +384 -0
  19. data/lib/redis/commands/strings.rb +314 -0
  20. data/lib/redis/commands/transactions.rb +115 -0
  21. data/lib/redis/commands.rb +235 -0
  22. data/lib/redis/distributed.rb +301 -109
  23. data/lib/redis/errors.rb +19 -1
  24. data/lib/redis/hash_ring.rb +34 -33
  25. data/lib/redis/pipeline.rb +69 -77
  26. data/lib/redis/subscribe.rb +26 -19
  27. data/lib/redis/version.rb +3 -1
  28. data/lib/redis.rb +109 -2728
  29. metadata +37 -229
  30. data/.gitignore +0 -16
  31. data/.travis/Gemfile +0 -13
  32. data/.travis.yml +0 -73
  33. data/.yardopts +0 -3
  34. data/Gemfile +0 -3
  35. data/benchmarking/logging.rb +0 -71
  36. data/benchmarking/pipeline.rb +0 -51
  37. data/benchmarking/speed.rb +0 -21
  38. data/benchmarking/suite.rb +0 -24
  39. data/benchmarking/worker.rb +0 -71
  40. data/bors.toml +0 -14
  41. data/examples/basic.rb +0 -15
  42. data/examples/consistency.rb +0 -114
  43. data/examples/dist_redis.rb +0 -43
  44. data/examples/incr-decr.rb +0 -17
  45. data/examples/list.rb +0 -26
  46. data/examples/pubsub.rb +0 -37
  47. data/examples/sentinel/sentinel.conf +0 -9
  48. data/examples/sentinel/start +0 -49
  49. data/examples/sentinel.rb +0 -41
  50. data/examples/sets.rb +0 -36
  51. data/examples/unicorn/config.ru +0 -3
  52. data/examples/unicorn/unicorn.rb +0 -20
  53. data/lib/redis/connection/command_helper.rb +0 -38
  54. data/lib/redis/connection/hiredis.rb +0 -66
  55. data/lib/redis/connection/registry.rb +0 -12
  56. data/lib/redis/connection/ruby.rb +0 -409
  57. data/lib/redis/connection/synchrony.rb +0 -141
  58. data/lib/redis/connection.rb +0 -9
  59. data/makefile +0 -42
  60. data/redis.gemspec +0 -42
  61. data/test/bitpos_test.rb +0 -63
  62. data/test/blocking_commands_test.rb +0 -40
  63. data/test/client_test.rb +0 -59
  64. data/test/command_map_test.rb +0 -28
  65. data/test/commands_on_hashes_test.rb +0 -19
  66. data/test/commands_on_hyper_log_log_test.rb +0 -19
  67. data/test/commands_on_lists_test.rb +0 -18
  68. data/test/commands_on_sets_test.rb +0 -75
  69. data/test/commands_on_sorted_sets_test.rb +0 -150
  70. data/test/commands_on_strings_test.rb +0 -99
  71. data/test/commands_on_value_types_test.rb +0 -131
  72. data/test/connection_handling_test.rb +0 -275
  73. data/test/db/.gitkeep +0 -0
  74. data/test/distributed_blocking_commands_test.rb +0 -44
  75. data/test/distributed_commands_on_hashes_test.rb +0 -8
  76. data/test/distributed_commands_on_hyper_log_log_test.rb +0 -31
  77. data/test/distributed_commands_on_lists_test.rb +0 -20
  78. data/test/distributed_commands_on_sets_test.rb +0 -81
  79. data/test/distributed_commands_on_sorted_sets_test.rb +0 -16
  80. data/test/distributed_commands_on_strings_test.rb +0 -57
  81. data/test/distributed_commands_on_value_types_test.rb +0 -93
  82. data/test/distributed_commands_requiring_clustering_test.rb +0 -162
  83. data/test/distributed_connection_handling_test.rb +0 -21
  84. data/test/distributed_internals_test.rb +0 -68
  85. data/test/distributed_key_tags_test.rb +0 -50
  86. data/test/distributed_persistence_control_commands_test.rb +0 -24
  87. data/test/distributed_publish_subscribe_test.rb +0 -90
  88. data/test/distributed_remote_server_control_commands_test.rb +0 -64
  89. data/test/distributed_scripting_test.rb +0 -100
  90. data/test/distributed_sorting_test.rb +0 -18
  91. data/test/distributed_test.rb +0 -56
  92. data/test/distributed_transactions_test.rb +0 -30
  93. data/test/encoding_test.rb +0 -14
  94. data/test/error_replies_test.rb +0 -57
  95. data/test/fork_safety_test.rb +0 -60
  96. data/test/helper.rb +0 -201
  97. data/test/helper_test.rb +0 -22
  98. data/test/internals_test.rb +0 -429
  99. data/test/lint/blocking_commands.rb +0 -150
  100. data/test/lint/hashes.rb +0 -162
  101. data/test/lint/hyper_log_log.rb +0 -60
  102. data/test/lint/lists.rb +0 -143
  103. data/test/lint/sets.rb +0 -140
  104. data/test/lint/sorted_sets.rb +0 -316
  105. data/test/lint/strings.rb +0 -246
  106. data/test/lint/value_types.rb +0 -130
  107. data/test/persistence_control_commands_test.rb +0 -24
  108. data/test/pipelining_commands_test.rb +0 -238
  109. data/test/publish_subscribe_test.rb +0 -280
  110. data/test/remote_server_control_commands_test.rb +0 -175
  111. data/test/scanning_test.rb +0 -407
  112. data/test/scripting_test.rb +0 -76
  113. data/test/sentinel_command_test.rb +0 -78
  114. data/test/sentinel_test.rb +0 -253
  115. data/test/sorting_test.rb +0 -57
  116. data/test/ssl_test.rb +0 -69
  117. data/test/support/connection/hiredis.rb +0 -1
  118. data/test/support/connection/ruby.rb +0 -1
  119. data/test/support/connection/synchrony.rb +0 -17
  120. data/test/support/redis_mock.rb +0 -130
  121. data/test/support/ssl/gen_certs.sh +0 -31
  122. data/test/support/ssl/trusted-ca.crt +0 -25
  123. data/test/support/ssl/trusted-ca.key +0 -27
  124. data/test/support/ssl/trusted-cert.crt +0 -81
  125. data/test/support/ssl/trusted-cert.key +0 -28
  126. data/test/support/ssl/untrusted-ca.crt +0 -26
  127. data/test/support/ssl/untrusted-ca.key +0 -27
  128. data/test/support/ssl/untrusted-cert.crt +0 -82
  129. data/test/support/ssl/untrusted-cert.key +0 -28
  130. data/test/support/wire/synchrony.rb +0 -24
  131. data/test/support/wire/thread.rb +0 -5
  132. data/test/synchrony_driver.rb +0 -85
  133. data/test/test.conf.erb +0 -9
  134. data/test/thread_safety_test.rb +0 -60
  135. data/test/transactions_test.rb +0 -262
  136. data/test/unknown_commands_test.rb +0 -12
  137. data/test/url_param_test.rb +0 -136
@@ -1,409 +0,0 @@
1
- require_relative "registry"
2
- require_relative "command_helper"
3
- require_relative "../errors"
4
- require "socket"
5
- require "timeout"
6
-
7
- begin
8
- require "openssl"
9
- rescue LoadError
10
- # Not all systems have OpenSSL support
11
- end
12
-
13
- class Redis
14
- module Connection
15
- module SocketMixin
16
-
17
- CRLF = "\r\n".freeze
18
-
19
- def initialize(*args)
20
- super(*args)
21
-
22
- @timeout = @write_timeout = nil
23
- @buffer = "".dup
24
- end
25
-
26
- def timeout=(timeout)
27
- if timeout && timeout > 0
28
- @timeout = timeout
29
- else
30
- @timeout = nil
31
- end
32
- end
33
-
34
- def write_timeout=(timeout)
35
- if timeout && timeout > 0
36
- @write_timeout = timeout
37
- else
38
- @write_timeout = nil
39
- end
40
- end
41
-
42
- def read(nbytes)
43
- result = @buffer.slice!(0, nbytes)
44
-
45
- while result.bytesize < nbytes
46
- result << _read_from_socket(nbytes - result.bytesize)
47
- end
48
-
49
- result
50
- end
51
-
52
- def gets
53
- crlf = nil
54
-
55
- while (crlf = @buffer.index(CRLF)) == nil
56
- @buffer << _read_from_socket(1024)
57
- end
58
-
59
- @buffer.slice!(0, crlf + CRLF.bytesize)
60
- end
61
-
62
- def _read_from_socket(nbytes)
63
-
64
- begin
65
- read_nonblock(nbytes)
66
-
67
- rescue IO::WaitReadable
68
- if IO.select([self], nil, nil, @timeout)
69
- retry
70
- else
71
- raise Redis::TimeoutError
72
- end
73
- rescue IO::WaitWritable
74
- if IO.select(nil, [self], nil, @timeout)
75
- retry
76
- else
77
- raise Redis::TimeoutError
78
- end
79
- end
80
-
81
- rescue EOFError
82
- raise Errno::ECONNRESET
83
- end
84
-
85
- def _write_to_socket(data)
86
- begin
87
- write_nonblock(data)
88
-
89
- rescue IO::WaitWritable
90
- if IO.select(nil, [self], nil, @write_timeout)
91
- retry
92
- else
93
- raise Redis::TimeoutError
94
- end
95
- rescue IO::WaitReadable
96
- if IO.select([self], nil, nil, @write_timeout)
97
- retry
98
- else
99
- raise Redis::TimeoutError
100
- end
101
- end
102
-
103
- rescue EOFError
104
- raise Errno::ECONNRESET
105
- end
106
-
107
- def write(data)
108
- return super(data) unless @write_timeout
109
-
110
- length = data.bytesize
111
- total_count = 0
112
- loop do
113
- count = _write_to_socket(data)
114
-
115
- total_count += count
116
- return total_count if total_count >= length
117
- data = data.byteslice(count..-1)
118
- end
119
- end
120
- end
121
-
122
- if defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
123
-
124
- require "timeout"
125
-
126
- class TCPSocket < ::TCPSocket
127
-
128
- include SocketMixin
129
-
130
- def self.connect(host, port, timeout)
131
- Timeout.timeout(timeout) do
132
- sock = new(host, port)
133
- sock
134
- end
135
- rescue Timeout::Error
136
- raise TimeoutError
137
- end
138
- end
139
-
140
- if defined?(::UNIXSocket)
141
-
142
- class UNIXSocket < ::UNIXSocket
143
-
144
- include SocketMixin
145
-
146
- def self.connect(path, timeout)
147
- Timeout.timeout(timeout) do
148
- sock = new(path)
149
- sock
150
- end
151
- rescue Timeout::Error
152
- raise TimeoutError
153
- end
154
-
155
- # JRuby raises Errno::EAGAIN on #read_nonblock even when IO.select
156
- # says it is readable (1.6.6, in both 1.8 and 1.9 mode).
157
- # Use the blocking #readpartial method instead.
158
-
159
- def _read_from_socket(nbytes)
160
- readpartial(nbytes)
161
-
162
- rescue EOFError
163
- raise Errno::ECONNRESET
164
- end
165
- end
166
-
167
- end
168
-
169
- else
170
-
171
- class TCPSocket < ::Socket
172
-
173
- include SocketMixin
174
-
175
- def self.connect_addrinfo(ai, port, timeout)
176
- sock = new(::Socket.const_get(ai[0]), Socket::SOCK_STREAM, 0)
177
- sockaddr = ::Socket.pack_sockaddr_in(port, ai[3])
178
-
179
- begin
180
- sock.connect_nonblock(sockaddr)
181
- rescue Errno::EINPROGRESS
182
- if IO.select(nil, [sock], nil, timeout) == nil
183
- raise TimeoutError
184
- end
185
-
186
- begin
187
- sock.connect_nonblock(sockaddr)
188
- rescue Errno::EISCONN
189
- end
190
- end
191
-
192
- sock
193
- end
194
-
195
- def self.connect(host, port, timeout)
196
- # Don't pass AI_ADDRCONFIG as flag to getaddrinfo(3)
197
- #
198
- # From the man page for getaddrinfo(3):
199
- #
200
- # If hints.ai_flags includes the AI_ADDRCONFIG flag, then IPv4
201
- # addresses are returned in the list pointed to by res only if the
202
- # local system has at least one IPv4 address configured, and IPv6
203
- # addresses are returned only if the local system has at least one
204
- # IPv6 address configured. The loopback address is not considered
205
- # for this case as valid as a configured address.
206
- #
207
- # We do want the IPv6 loopback address to be returned if applicable,
208
- # even if it is the only configured IPv6 address on the machine.
209
- # Also see: https://github.com/redis/redis-rb/pull/394.
210
- addrinfo = ::Socket.getaddrinfo(host, nil, Socket::AF_UNSPEC, Socket::SOCK_STREAM)
211
-
212
- # From the man page for getaddrinfo(3):
213
- #
214
- # Normally, the application should try using the addresses in the
215
- # order in which they are returned. The sorting function used
216
- # within getaddrinfo() is defined in RFC 3484 [...].
217
- #
218
- addrinfo.each_with_index do |ai, i|
219
- begin
220
- return connect_addrinfo(ai, port, timeout)
221
- rescue SystemCallError
222
- # Raise if this was our last attempt.
223
- raise if addrinfo.length == i+1
224
- end
225
- end
226
- end
227
- end
228
-
229
- class UNIXSocket < ::Socket
230
-
231
- include SocketMixin
232
-
233
- def self.connect(path, timeout)
234
- sock = new(::Socket::AF_UNIX, Socket::SOCK_STREAM, 0)
235
- sockaddr = ::Socket.pack_sockaddr_un(path)
236
-
237
- begin
238
- sock.connect_nonblock(sockaddr)
239
- rescue Errno::EINPROGRESS
240
- if IO.select(nil, [sock], nil, timeout) == nil
241
- raise TimeoutError
242
- end
243
-
244
- begin
245
- sock.connect_nonblock(sockaddr)
246
- rescue Errno::EISCONN
247
- end
248
- end
249
-
250
- sock
251
- end
252
- end
253
-
254
- end
255
-
256
- if defined?(OpenSSL)
257
- class SSLSocket < ::OpenSSL::SSL::SSLSocket
258
- include SocketMixin
259
-
260
- def self.connect(host, port, timeout, ssl_params)
261
- # Note: this is using Redis::Connection::TCPSocket
262
- tcp_sock = TCPSocket.connect(host, port, timeout)
263
-
264
- ctx = OpenSSL::SSL::SSLContext.new
265
- ctx.set_params(ssl_params) if ssl_params && !ssl_params.empty?
266
-
267
- ssl_sock = new(tcp_sock, ctx)
268
- ssl_sock.hostname = host
269
- ssl_sock.connect
270
- ssl_sock.post_connection_check(host)
271
-
272
- ssl_sock
273
- end
274
- end
275
- end
276
-
277
- class Ruby
278
- include Redis::Connection::CommandHelper
279
-
280
- MINUS = "-".freeze
281
- PLUS = "+".freeze
282
- COLON = ":".freeze
283
- DOLLAR = "$".freeze
284
- ASTERISK = "*".freeze
285
-
286
- def self.connect(config)
287
- if config[:scheme] == "unix"
288
- raise ArgumentError, "SSL incompatible with unix sockets" if config[:ssl]
289
- sock = UNIXSocket.connect(config[:path], config[:connect_timeout])
290
- elsif config[:scheme] == "rediss" || config[:ssl]
291
- sock = SSLSocket.connect(config[:host], config[:port], config[:connect_timeout], config[:ssl_params])
292
- else
293
- sock = TCPSocket.connect(config[:host], config[:port], config[:connect_timeout])
294
- end
295
-
296
- instance = new(sock)
297
- instance.timeout = config[:timeout]
298
- instance.write_timeout = config[:write_timeout]
299
- instance.set_tcp_keepalive config[:tcp_keepalive]
300
- instance
301
- end
302
-
303
- if [:SOL_SOCKET, :SO_KEEPALIVE, :SOL_TCP, :TCP_KEEPIDLE, :TCP_KEEPINTVL, :TCP_KEEPCNT].all?{|c| Socket.const_defined? c}
304
- def set_tcp_keepalive(keepalive)
305
- return unless keepalive.is_a?(Hash)
306
-
307
- @sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, true)
308
- @sock.setsockopt(Socket::SOL_TCP, Socket::TCP_KEEPIDLE, keepalive[:time])
309
- @sock.setsockopt(Socket::SOL_TCP, Socket::TCP_KEEPINTVL, keepalive[:intvl])
310
- @sock.setsockopt(Socket::SOL_TCP, Socket::TCP_KEEPCNT, keepalive[:probes])
311
- end
312
-
313
- def get_tcp_keepalive
314
- {
315
- :time => @sock.getsockopt(Socket::SOL_TCP, Socket::TCP_KEEPIDLE).int,
316
- :intvl => @sock.getsockopt(Socket::SOL_TCP, Socket::TCP_KEEPINTVL).int,
317
- :probes => @sock.getsockopt(Socket::SOL_TCP, Socket::TCP_KEEPCNT).int,
318
- }
319
- end
320
- else
321
- def set_tcp_keepalive(keepalive)
322
- end
323
-
324
- def get_tcp_keepalive
325
- {
326
- }
327
- end
328
- end
329
-
330
- def initialize(sock)
331
- @sock = sock
332
- end
333
-
334
- def connected?
335
- !! @sock
336
- end
337
-
338
- def disconnect
339
- @sock.close
340
- rescue
341
- ensure
342
- @sock = nil
343
- end
344
-
345
- def timeout=(timeout)
346
- if @sock.respond_to?(:timeout=)
347
- @sock.timeout = timeout
348
- end
349
- end
350
-
351
- def write_timeout=(timeout)
352
- @sock.write_timeout = timeout
353
- end
354
-
355
- def write(command)
356
- @sock.write(build_command(command))
357
- end
358
-
359
- def read
360
- line = @sock.gets
361
- reply_type = line.slice!(0, 1)
362
- format_reply(reply_type, line)
363
-
364
- rescue Errno::EAGAIN
365
- raise TimeoutError
366
- end
367
-
368
- def format_reply(reply_type, line)
369
- case reply_type
370
- when MINUS then format_error_reply(line)
371
- when PLUS then format_status_reply(line)
372
- when COLON then format_integer_reply(line)
373
- when DOLLAR then format_bulk_reply(line)
374
- when ASTERISK then format_multi_bulk_reply(line)
375
- else raise ProtocolError.new(reply_type)
376
- end
377
- end
378
-
379
- def format_error_reply(line)
380
- CommandError.new(line.strip)
381
- end
382
-
383
- def format_status_reply(line)
384
- line.strip
385
- end
386
-
387
- def format_integer_reply(line)
388
- line.to_i
389
- end
390
-
391
- def format_bulk_reply(line)
392
- bulklen = line.to_i
393
- return if bulklen == -1
394
- reply = encode(@sock.read(bulklen))
395
- @sock.read(2) # Discard CRLF.
396
- reply
397
- end
398
-
399
- def format_multi_bulk_reply(line)
400
- n = line.to_i
401
- return if n == -1
402
-
403
- Array.new(n) { read }
404
- end
405
- end
406
- end
407
- end
408
-
409
- Redis::Connection.drivers << Redis::Connection::Ruby
@@ -1,141 +0,0 @@
1
- require_relative "command_helper"
2
- require_relative "registry"
3
- require_relative "../errors"
4
- require "em-synchrony"
5
- require "hiredis/reader"
6
-
7
- class Redis
8
- module Connection
9
- class RedisClient < EventMachine::Connection
10
- include EventMachine::Deferrable
11
-
12
- attr_accessor :timeout
13
-
14
- def post_init
15
- @req = nil
16
- @connected = false
17
- @reader = ::Hiredis::Reader.new
18
- end
19
-
20
- def connection_completed
21
- @connected = true
22
- succeed
23
- end
24
-
25
- def connected?
26
- @connected
27
- end
28
-
29
- def receive_data(data)
30
- @reader.feed(data)
31
-
32
- loop do
33
- begin
34
- reply = @reader.gets
35
- rescue RuntimeError => err
36
- @req.fail [:error, ProtocolError.new(err.message)]
37
- break
38
- end
39
-
40
- break if reply == false
41
-
42
- reply = CommandError.new(reply.message) if reply.is_a?(RuntimeError)
43
- @req.succeed [:reply, reply]
44
- end
45
- end
46
-
47
- def read
48
- @req = EventMachine::DefaultDeferrable.new
49
- if @timeout > 0
50
- @req.timeout(@timeout, :timeout)
51
- end
52
- EventMachine::Synchrony.sync @req
53
- end
54
-
55
- def send(data)
56
- callback { send_data data }
57
- end
58
-
59
- def unbind
60
- @connected = false
61
- if @req
62
- @req.fail [:error, Errno::ECONNRESET]
63
- @req = nil
64
- else
65
- fail
66
- end
67
- end
68
- end
69
-
70
- class Synchrony
71
- include Redis::Connection::CommandHelper
72
-
73
- def self.connect(config)
74
- if config[:scheme] == "unix"
75
- begin
76
- conn = EventMachine.connect_unix_domain(config[:path], RedisClient)
77
- rescue RuntimeError => e
78
- if e.message == "no connection"
79
- raise Errno::ECONNREFUSED
80
- else
81
- raise e
82
- end
83
- end
84
- elsif config[:scheme] == "rediss" || config[:ssl]
85
- raise NotImplementedError, "SSL not supported by synchrony driver"
86
- else
87
- conn = EventMachine.connect(config[:host], config[:port], RedisClient) do |c|
88
- c.pending_connect_timeout = [config[:connect_timeout], 0.1].max
89
- end
90
- end
91
-
92
- fiber = Fiber.current
93
- conn.callback { fiber.resume }
94
- conn.errback { fiber.resume :refused }
95
-
96
- raise Errno::ECONNREFUSED if Fiber.yield == :refused
97
-
98
- instance = new(conn)
99
- instance.timeout = config[:read_timeout]
100
- instance
101
- end
102
-
103
- def initialize(connection)
104
- @connection = connection
105
- end
106
-
107
- def connected?
108
- @connection && @connection.connected?
109
- end
110
-
111
- def timeout=(timeout)
112
- @connection.timeout = timeout
113
- end
114
-
115
- def disconnect
116
- @connection.close_connection
117
- @connection = nil
118
- end
119
-
120
- def write(command)
121
- @connection.send(build_command(command))
122
- end
123
-
124
- def read
125
- type, payload = @connection.read
126
-
127
- if type == :reply
128
- payload
129
- elsif type == :error
130
- raise payload
131
- elsif type == :timeout
132
- raise TimeoutError
133
- else
134
- raise "Unknown type #{type.inspect}"
135
- end
136
- end
137
- end
138
- end
139
- end
140
-
141
- Redis::Connection.drivers << Redis::Connection::Synchrony
@@ -1,9 +0,0 @@
1
- require_relative "connection/registry"
2
-
3
- # If a connection driver was required before this file, the array
4
- # Redis::Connection.drivers will contain one or more classes. The last driver
5
- # in this array will be used as default driver. If this array is empty, we load
6
- # the plain Ruby driver as our default. Another driver can be required at a
7
- # later point in time, causing it to be the last element of the #drivers array
8
- # and therefore be chosen by default.
9
- require_relative "connection/ruby" if Redis::Connection.drivers.empty?
data/makefile DELETED
@@ -1,42 +0,0 @@
1
- TEST_FILES := $(shell find test -name *_test.rb -type f)
2
- REDIS_BRANCH := unstable
3
- TMP := tmp
4
- BUILD_DIR := ${TMP}/redis-${REDIS_BRANCH}
5
- TARBALL := ${TMP}/redis-${REDIS_BRANCH}.tar.gz
6
- BINARY := ${BUILD_DIR}/src/redis-server
7
- PID_PATH := ${BUILD_DIR}/redis.pid
8
- SOCKET_PATH := ${BUILD_DIR}/redis.sock
9
- PORT := 6381
10
-
11
- test: ${TEST_FILES}
12
- make start
13
- env SOCKET_PATH=${SOCKET_PATH} \
14
- ruby -v $$(echo $? | tr ' ' '\n' | awk '{ print "-r./" $$0 }') -e ''
15
- make stop
16
-
17
- ${TMP}:
18
- mkdir $@
19
-
20
- ${TARBALL}: ${TMP}
21
- wget https://github.com/antirez/redis/archive/${REDIS_BRANCH}.tar.gz -O $@
22
-
23
- ${BINARY}: ${TARBALL} ${TMP}
24
- rm -rf ${BUILD_DIR}
25
- mkdir -p ${BUILD_DIR}
26
- tar xf ${TARBALL} -C ${TMP}
27
- cd ${BUILD_DIR} && make
28
-
29
- stop:
30
- (test -f ${PID_PATH} && (kill $$(cat ${PID_PATH}) || true) && rm -f ${PID_PATH}) || true
31
-
32
- start: ${BINARY}
33
- ${BINARY} \
34
- --daemonize yes \
35
- --pidfile ${PID_PATH} \
36
- --port ${PORT} \
37
- --unixsocket ${SOCKET_PATH}
38
-
39
- clean:
40
- (test -d ${BUILD_DIR} && cd ${BUILD_DIR}/src && make clean distclean) || true
41
-
42
- .PHONY: test start stop
data/redis.gemspec DELETED
@@ -1,42 +0,0 @@
1
- require "./lib/redis/version"
2
-
3
- Gem::Specification.new do |s|
4
- s.name = "redis"
5
-
6
- s.version = Redis::VERSION
7
-
8
- s.homepage = "https://github.com/redis/redis-rb"
9
-
10
- s.summary = "A Ruby client library for Redis"
11
-
12
- s.description = <<-EOS
13
- A Ruby client that tries to match Redis' API one-to-one, while still
14
- providing an idiomatic interface.
15
- EOS
16
-
17
- s.license = "MIT"
18
-
19
- s.authors = [
20
- "Ezra Zygmuntowicz",
21
- "Taylor Weibley",
22
- "Matthew Clark",
23
- "Brian McKinney",
24
- "Salvatore Sanfilippo",
25
- "Luca Guidi",
26
- "Michel Martens",
27
- "Damian Janowski",
28
- "Pieter Noordhuis"
29
- ]
30
-
31
- s.email = ["redis-db@googlegroups.com"]
32
-
33
- s.files = `git ls-files`.split("\n")
34
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
35
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
36
-
37
- s.required_ruby_version = '>= 2.2.2'
38
-
39
- s.add_development_dependency("test-unit", ">= 3.1.5")
40
- s.add_development_dependency("hiredis")
41
- s.add_development_dependency("em-synchrony")
42
- end
data/test/bitpos_test.rb DELETED
@@ -1,63 +0,0 @@
1
- require_relative "helper"
2
-
3
- class TestBitpos < Test::Unit::TestCase
4
-
5
- include Helper::Client
6
-
7
- def test_bitpos_empty_zero
8
- target_version "2.9.11" do
9
- r.del "foo"
10
- assert_equal(0, r.bitpos("foo", 0))
11
- end
12
- end
13
-
14
- def test_bitpos_empty_one
15
- target_version "2.9.11" do
16
- r.del "foo"
17
- assert_equal(-1, r.bitpos("foo", 1))
18
- end
19
- end
20
-
21
- def test_bitpos_zero
22
- target_version "2.9.11" do
23
- r.set "foo", "\xff\xf0\x00"
24
- assert_equal(12, r.bitpos("foo", 0))
25
- end
26
- end
27
-
28
- def test_bitpos_one
29
- target_version "2.9.11" do
30
- r.set "foo", "\x00\x0f\x00"
31
- assert_equal(12, r.bitpos("foo", 1))
32
- end
33
- end
34
-
35
- def test_bitpos_zero_end_is_given
36
- target_version "2.9.11" do
37
- r.set "foo", "\xff\xff\xff"
38
- assert_equal(24, r.bitpos("foo", 0))
39
- assert_equal(24, r.bitpos("foo", 0, 0))
40
- assert_equal(-1, r.bitpos("foo", 0, 0, -1))
41
- end
42
- end
43
-
44
- def test_bitpos_one_intervals
45
- target_version "2.9.11" do
46
- r.set "foo", "\x00\xff\x00"
47
- assert_equal(8, r.bitpos("foo", 1, 0, -1))
48
- assert_equal(8, r.bitpos("foo", 1, 1, -1))
49
- assert_equal(-1, r.bitpos("foo", 1, 2, -1))
50
- assert_equal(-1, r.bitpos("foo", 1, 2, 200))
51
- assert_equal(8, r.bitpos("foo", 1, 1, 1))
52
- end
53
- end
54
-
55
- def test_bitpos_raise_exception_if_stop_not_start
56
- target_version "2.9.11" do
57
- assert_raises(ArgumentError) do
58
- r.bitpos("foo", 0, nil, 2)
59
- end
60
- end
61
- end
62
-
63
- end