redis 3.2.0 → 4.6.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 (133) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +278 -15
  3. data/README.md +260 -76
  4. data/lib/redis/client.rb +239 -115
  5. data/lib/redis/cluster/command.rb +79 -0
  6. data/lib/redis/cluster/command_loader.rb +33 -0
  7. data/lib/redis/cluster/key_slot_converter.rb +72 -0
  8. data/lib/redis/cluster/node.rb +120 -0
  9. data/lib/redis/cluster/node_key.rb +31 -0
  10. data/lib/redis/cluster/node_loader.rb +37 -0
  11. data/lib/redis/cluster/option.rb +93 -0
  12. data/lib/redis/cluster/slot.rb +86 -0
  13. data/lib/redis/cluster/slot_loader.rb +49 -0
  14. data/lib/redis/cluster.rb +315 -0
  15. data/lib/redis/commands/bitmaps.rb +63 -0
  16. data/lib/redis/commands/cluster.rb +45 -0
  17. data/lib/redis/commands/connection.rb +58 -0
  18. data/lib/redis/commands/geo.rb +84 -0
  19. data/lib/redis/commands/hashes.rb +251 -0
  20. data/lib/redis/commands/hyper_log_log.rb +37 -0
  21. data/lib/redis/commands/keys.rb +411 -0
  22. data/lib/redis/commands/lists.rb +289 -0
  23. data/lib/redis/commands/pubsub.rb +72 -0
  24. data/lib/redis/commands/scripting.rb +114 -0
  25. data/lib/redis/commands/server.rb +188 -0
  26. data/lib/redis/commands/sets.rb +207 -0
  27. data/lib/redis/commands/sorted_sets.rb +804 -0
  28. data/lib/redis/commands/streams.rb +382 -0
  29. data/lib/redis/commands/strings.rb +313 -0
  30. data/lib/redis/commands/transactions.rb +92 -0
  31. data/lib/redis/commands.rb +242 -0
  32. data/lib/redis/connection/command_helper.rb +7 -10
  33. data/lib/redis/connection/hiredis.rb +11 -6
  34. data/lib/redis/connection/registry.rb +2 -1
  35. data/lib/redis/connection/ruby.rb +173 -64
  36. data/lib/redis/connection/synchrony.rb +32 -8
  37. data/lib/redis/connection.rb +3 -1
  38. data/lib/redis/distributed.rb +233 -74
  39. data/lib/redis/errors.rb +48 -0
  40. data/lib/redis/hash_ring.rb +30 -72
  41. data/lib/redis/pipeline.rb +145 -12
  42. data/lib/redis/subscribe.rb +20 -13
  43. data/lib/redis/version.rb +3 -1
  44. data/lib/redis.rb +171 -2476
  45. metadata +71 -165
  46. data/.gitignore +0 -15
  47. data/.travis/Gemfile +0 -11
  48. data/.travis.yml +0 -54
  49. data/.yardopts +0 -3
  50. data/Gemfile +0 -4
  51. data/Rakefile +0 -68
  52. data/benchmarking/logging.rb +0 -71
  53. data/benchmarking/pipeline.rb +0 -51
  54. data/benchmarking/speed.rb +0 -21
  55. data/benchmarking/suite.rb +0 -24
  56. data/benchmarking/worker.rb +0 -71
  57. data/examples/basic.rb +0 -15
  58. data/examples/consistency.rb +0 -114
  59. data/examples/dist_redis.rb +0 -43
  60. data/examples/incr-decr.rb +0 -17
  61. data/examples/list.rb +0 -26
  62. data/examples/pubsub.rb +0 -37
  63. data/examples/sentinel/sentinel.conf +0 -9
  64. data/examples/sentinel/start +0 -49
  65. data/examples/sentinel.rb +0 -41
  66. data/examples/sets.rb +0 -36
  67. data/examples/unicorn/config.ru +0 -3
  68. data/examples/unicorn/unicorn.rb +0 -20
  69. data/redis.gemspec +0 -43
  70. data/test/bitpos_test.rb +0 -69
  71. data/test/blocking_commands_test.rb +0 -42
  72. data/test/command_map_test.rb +0 -30
  73. data/test/commands_on_hashes_test.rb +0 -21
  74. data/test/commands_on_hyper_log_log_test.rb +0 -21
  75. data/test/commands_on_lists_test.rb +0 -20
  76. data/test/commands_on_sets_test.rb +0 -77
  77. data/test/commands_on_sorted_sets_test.rb +0 -123
  78. data/test/commands_on_strings_test.rb +0 -101
  79. data/test/commands_on_value_types_test.rb +0 -131
  80. data/test/connection_handling_test.rb +0 -189
  81. data/test/db/.gitkeep +0 -0
  82. data/test/distributed_blocking_commands_test.rb +0 -46
  83. data/test/distributed_commands_on_hashes_test.rb +0 -10
  84. data/test/distributed_commands_on_hyper_log_log_test.rb +0 -33
  85. data/test/distributed_commands_on_lists_test.rb +0 -22
  86. data/test/distributed_commands_on_sets_test.rb +0 -83
  87. data/test/distributed_commands_on_sorted_sets_test.rb +0 -18
  88. data/test/distributed_commands_on_strings_test.rb +0 -59
  89. data/test/distributed_commands_on_value_types_test.rb +0 -95
  90. data/test/distributed_commands_requiring_clustering_test.rb +0 -164
  91. data/test/distributed_connection_handling_test.rb +0 -23
  92. data/test/distributed_internals_test.rb +0 -70
  93. data/test/distributed_key_tags_test.rb +0 -52
  94. data/test/distributed_persistence_control_commands_test.rb +0 -26
  95. data/test/distributed_publish_subscribe_test.rb +0 -92
  96. data/test/distributed_remote_server_control_commands_test.rb +0 -66
  97. data/test/distributed_scripting_test.rb +0 -102
  98. data/test/distributed_sorting_test.rb +0 -20
  99. data/test/distributed_test.rb +0 -58
  100. data/test/distributed_transactions_test.rb +0 -32
  101. data/test/encoding_test.rb +0 -18
  102. data/test/error_replies_test.rb +0 -59
  103. data/test/fork_safety_test.rb +0 -65
  104. data/test/helper.rb +0 -232
  105. data/test/helper_test.rb +0 -24
  106. data/test/internals_test.rb +0 -434
  107. data/test/lint/blocking_commands.rb +0 -150
  108. data/test/lint/hashes.rb +0 -162
  109. data/test/lint/hyper_log_log.rb +0 -60
  110. data/test/lint/lists.rb +0 -143
  111. data/test/lint/sets.rb +0 -125
  112. data/test/lint/sorted_sets.rb +0 -238
  113. data/test/lint/strings.rb +0 -260
  114. data/test/lint/value_types.rb +0 -122
  115. data/test/persistence_control_commands_test.rb +0 -26
  116. data/test/pipelining_commands_test.rb +0 -242
  117. data/test/publish_subscribe_test.rb +0 -210
  118. data/test/remote_server_control_commands_test.rb +0 -117
  119. data/test/scanning_test.rb +0 -413
  120. data/test/scripting_test.rb +0 -78
  121. data/test/sorting_test.rb +0 -59
  122. data/test/support/connection/hiredis.rb +0 -1
  123. data/test/support/connection/ruby.rb +0 -1
  124. data/test/support/connection/synchrony.rb +0 -17
  125. data/test/support/redis_mock.rb +0 -115
  126. data/test/support/wire/synchrony.rb +0 -24
  127. data/test/support/wire/thread.rb +0 -5
  128. data/test/synchrony_driver.rb +0 -88
  129. data/test/test.conf +0 -9
  130. data/test/thread_safety_test.rb +0 -32
  131. data/test/transactions_test.rb +0 -264
  132. data/test/unknown_commands_test.rb +0 -14
  133. data/test/url_param_test.rb +0 -132
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 4.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ezra Zygmuntowicz
@@ -13,13 +13,41 @@ authors:
13
13
  - Michel Martens
14
14
  - Damian Janowski
15
15
  - Pieter Noordhuis
16
- autorequire:
16
+ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
- date: 2014-12-11 00:00:00.000000000 Z
19
+ date: 2022-02-02 00:00:00.000000000 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: rake
22
+ name: em-synchrony
23
+ requirement: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ type: :development
29
+ prerelease: false
30
+ version_requirements: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ - !ruby/object:Gem::Dependency
36
+ name: hiredis
37
+ requirement: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ type: :development
43
+ prerelease: false
44
+ version_requirements: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ - !ruby/object:Gem::Dependency
50
+ name: mocha
23
51
  requirement: !ruby/object:Gem::Requirement
24
52
  requirements:
25
53
  - - ">="
@@ -34,42 +62,45 @@ dependencies:
34
62
  version: '0'
35
63
  description: |2
36
64
  A Ruby client that tries to match Redis' API one-to-one, while still
37
- providing an idiomatic interface. It features thread-safety,
38
- client-side sharding, pipelining, and an obsession for performance.
65
+ providing an idiomatic interface.
39
66
  email:
40
67
  - redis-db@googlegroups.com
41
68
  executables: []
42
69
  extensions: []
43
70
  extra_rdoc_files: []
44
71
  files:
45
- - ".gitignore"
46
- - ".travis.yml"
47
- - ".travis/Gemfile"
48
- - ".yardopts"
49
72
  - CHANGELOG.md
50
- - Gemfile
51
73
  - LICENSE
52
74
  - README.md
53
- - Rakefile
54
- - benchmarking/logging.rb
55
- - benchmarking/pipeline.rb
56
- - benchmarking/speed.rb
57
- - benchmarking/suite.rb
58
- - benchmarking/worker.rb
59
- - examples/basic.rb
60
- - examples/consistency.rb
61
- - examples/dist_redis.rb
62
- - examples/incr-decr.rb
63
- - examples/list.rb
64
- - examples/pubsub.rb
65
- - examples/sentinel.rb
66
- - examples/sentinel/sentinel.conf
67
- - examples/sentinel/start
68
- - examples/sets.rb
69
- - examples/unicorn/config.ru
70
- - examples/unicorn/unicorn.rb
71
75
  - lib/redis.rb
72
76
  - lib/redis/client.rb
77
+ - lib/redis/cluster.rb
78
+ - lib/redis/cluster/command.rb
79
+ - lib/redis/cluster/command_loader.rb
80
+ - lib/redis/cluster/key_slot_converter.rb
81
+ - lib/redis/cluster/node.rb
82
+ - lib/redis/cluster/node_key.rb
83
+ - lib/redis/cluster/node_loader.rb
84
+ - lib/redis/cluster/option.rb
85
+ - lib/redis/cluster/slot.rb
86
+ - lib/redis/cluster/slot_loader.rb
87
+ - lib/redis/commands.rb
88
+ - lib/redis/commands/bitmaps.rb
89
+ - lib/redis/commands/cluster.rb
90
+ - lib/redis/commands/connection.rb
91
+ - lib/redis/commands/geo.rb
92
+ - lib/redis/commands/hashes.rb
93
+ - lib/redis/commands/hyper_log_log.rb
94
+ - lib/redis/commands/keys.rb
95
+ - lib/redis/commands/lists.rb
96
+ - lib/redis/commands/pubsub.rb
97
+ - lib/redis/commands/scripting.rb
98
+ - lib/redis/commands/server.rb
99
+ - lib/redis/commands/sets.rb
100
+ - lib/redis/commands/sorted_sets.rb
101
+ - lib/redis/commands/streams.rb
102
+ - lib/redis/commands/strings.rb
103
+ - lib/redis/commands/transactions.rb
73
104
  - lib/redis/connection.rb
74
105
  - lib/redis/connection/command_helper.rb
75
106
  - lib/redis/connection/hiredis.rb
@@ -82,76 +113,16 @@ files:
82
113
  - lib/redis/pipeline.rb
83
114
  - lib/redis/subscribe.rb
84
115
  - lib/redis/version.rb
85
- - redis.gemspec
86
- - test/bitpos_test.rb
87
- - test/blocking_commands_test.rb
88
- - test/command_map_test.rb
89
- - test/commands_on_hashes_test.rb
90
- - test/commands_on_hyper_log_log_test.rb
91
- - test/commands_on_lists_test.rb
92
- - test/commands_on_sets_test.rb
93
- - test/commands_on_sorted_sets_test.rb
94
- - test/commands_on_strings_test.rb
95
- - test/commands_on_value_types_test.rb
96
- - test/connection_handling_test.rb
97
- - test/db/.gitkeep
98
- - test/distributed_blocking_commands_test.rb
99
- - test/distributed_commands_on_hashes_test.rb
100
- - test/distributed_commands_on_hyper_log_log_test.rb
101
- - test/distributed_commands_on_lists_test.rb
102
- - test/distributed_commands_on_sets_test.rb
103
- - test/distributed_commands_on_sorted_sets_test.rb
104
- - test/distributed_commands_on_strings_test.rb
105
- - test/distributed_commands_on_value_types_test.rb
106
- - test/distributed_commands_requiring_clustering_test.rb
107
- - test/distributed_connection_handling_test.rb
108
- - test/distributed_internals_test.rb
109
- - test/distributed_key_tags_test.rb
110
- - test/distributed_persistence_control_commands_test.rb
111
- - test/distributed_publish_subscribe_test.rb
112
- - test/distributed_remote_server_control_commands_test.rb
113
- - test/distributed_scripting_test.rb
114
- - test/distributed_sorting_test.rb
115
- - test/distributed_test.rb
116
- - test/distributed_transactions_test.rb
117
- - test/encoding_test.rb
118
- - test/error_replies_test.rb
119
- - test/fork_safety_test.rb
120
- - test/helper.rb
121
- - test/helper_test.rb
122
- - test/internals_test.rb
123
- - test/lint/blocking_commands.rb
124
- - test/lint/hashes.rb
125
- - test/lint/hyper_log_log.rb
126
- - test/lint/lists.rb
127
- - test/lint/sets.rb
128
- - test/lint/sorted_sets.rb
129
- - test/lint/strings.rb
130
- - test/lint/value_types.rb
131
- - test/persistence_control_commands_test.rb
132
- - test/pipelining_commands_test.rb
133
- - test/publish_subscribe_test.rb
134
- - test/remote_server_control_commands_test.rb
135
- - test/scanning_test.rb
136
- - test/scripting_test.rb
137
- - test/sorting_test.rb
138
- - test/support/connection/hiredis.rb
139
- - test/support/connection/ruby.rb
140
- - test/support/connection/synchrony.rb
141
- - test/support/redis_mock.rb
142
- - test/support/wire/synchrony.rb
143
- - test/support/wire/thread.rb
144
- - test/synchrony_driver.rb
145
- - test/test.conf
146
- - test/thread_safety_test.rb
147
- - test/transactions_test.rb
148
- - test/unknown_commands_test.rb
149
- - test/url_param_test.rb
150
116
  homepage: https://github.com/redis/redis-rb
151
117
  licenses:
152
118
  - MIT
153
- metadata: {}
154
- post_install_message:
119
+ metadata:
120
+ bug_tracker_uri: https://github.com/redis/redis-rb/issues
121
+ changelog_uri: https://github.com/redis/redis-rb/blob/master/CHANGELOG.md
122
+ documentation_uri: https://www.rubydoc.info/gems/redis/4.6.0
123
+ homepage_uri: https://github.com/redis/redis-rb
124
+ source_code_uri: https://github.com/redis/redis-rb/tree/v4.6.0
125
+ post_install_message:
155
126
  rdoc_options: []
156
127
  require_paths:
157
128
  - lib
@@ -159,80 +130,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
159
130
  requirements:
160
131
  - - ">="
161
132
  - !ruby/object:Gem::Version
162
- version: '0'
133
+ version: 2.4.0
163
134
  required_rubygems_version: !ruby/object:Gem::Requirement
164
135
  requirements:
165
136
  - - ">="
166
137
  - !ruby/object:Gem::Version
167
138
  version: '0'
168
139
  requirements: []
169
- rubyforge_project:
170
- rubygems_version: 2.2.2
171
- signing_key:
140
+ rubygems_version: 3.1.2
141
+ signing_key:
172
142
  specification_version: 4
173
143
  summary: A Ruby client library for Redis
174
- test_files:
175
- - test/bitpos_test.rb
176
- - test/blocking_commands_test.rb
177
- - test/command_map_test.rb
178
- - test/commands_on_hashes_test.rb
179
- - test/commands_on_hyper_log_log_test.rb
180
- - test/commands_on_lists_test.rb
181
- - test/commands_on_sets_test.rb
182
- - test/commands_on_sorted_sets_test.rb
183
- - test/commands_on_strings_test.rb
184
- - test/commands_on_value_types_test.rb
185
- - test/connection_handling_test.rb
186
- - test/db/.gitkeep
187
- - test/distributed_blocking_commands_test.rb
188
- - test/distributed_commands_on_hashes_test.rb
189
- - test/distributed_commands_on_hyper_log_log_test.rb
190
- - test/distributed_commands_on_lists_test.rb
191
- - test/distributed_commands_on_sets_test.rb
192
- - test/distributed_commands_on_sorted_sets_test.rb
193
- - test/distributed_commands_on_strings_test.rb
194
- - test/distributed_commands_on_value_types_test.rb
195
- - test/distributed_commands_requiring_clustering_test.rb
196
- - test/distributed_connection_handling_test.rb
197
- - test/distributed_internals_test.rb
198
- - test/distributed_key_tags_test.rb
199
- - test/distributed_persistence_control_commands_test.rb
200
- - test/distributed_publish_subscribe_test.rb
201
- - test/distributed_remote_server_control_commands_test.rb
202
- - test/distributed_scripting_test.rb
203
- - test/distributed_sorting_test.rb
204
- - test/distributed_test.rb
205
- - test/distributed_transactions_test.rb
206
- - test/encoding_test.rb
207
- - test/error_replies_test.rb
208
- - test/fork_safety_test.rb
209
- - test/helper.rb
210
- - test/helper_test.rb
211
- - test/internals_test.rb
212
- - test/lint/blocking_commands.rb
213
- - test/lint/hashes.rb
214
- - test/lint/hyper_log_log.rb
215
- - test/lint/lists.rb
216
- - test/lint/sets.rb
217
- - test/lint/sorted_sets.rb
218
- - test/lint/strings.rb
219
- - test/lint/value_types.rb
220
- - test/persistence_control_commands_test.rb
221
- - test/pipelining_commands_test.rb
222
- - test/publish_subscribe_test.rb
223
- - test/remote_server_control_commands_test.rb
224
- - test/scanning_test.rb
225
- - test/scripting_test.rb
226
- - test/sorting_test.rb
227
- - test/support/connection/hiredis.rb
228
- - test/support/connection/ruby.rb
229
- - test/support/connection/synchrony.rb
230
- - test/support/redis_mock.rb
231
- - test/support/wire/synchrony.rb
232
- - test/support/wire/thread.rb
233
- - test/synchrony_driver.rb
234
- - test/test.conf
235
- - test/thread_safety_test.rb
236
- - test/transactions_test.rb
237
- - test/unknown_commands_test.rb
238
- - test/url_param_test.rb
144
+ test_files: []
data/.gitignore DELETED
@@ -1,15 +0,0 @@
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
data/.travis/Gemfile DELETED
@@ -1,11 +0,0 @@
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
data/.travis.yml DELETED
@@ -1,54 +0,0 @@
1
- language: ruby
2
-
3
- rvm:
4
- - 1.8.7
5
- - 1.9.3
6
- - 2.1
7
- - jruby-18mode
8
- - jruby-19mode
9
-
10
- gemfile: ".travis/Gemfile"
11
-
12
- sudo: false
13
-
14
- env:
15
- global:
16
- - VERBOSE=true
17
- - TIMEOUT=1
18
- matrix:
19
- - conn=ruby REDIS_BRANCH=2.8
20
- - conn=hiredis REDIS_BRANCH=2.8
21
- - conn=synchrony REDIS_BRANCH=2.8
22
- - conn=ruby REDIS_BRANCH=unstable
23
-
24
- branches:
25
- only:
26
- - master
27
-
28
- matrix:
29
- exclude:
30
- # hiredis
31
- - rvm: jruby-18mode
32
- gemfile: .travis/Gemfile
33
- env: conn=hiredis REDIS_BRANCH=2.8
34
- - rvm: jruby-19mode
35
- gemfile: .travis/Gemfile
36
- env: conn=hiredis REDIS_BRANCH=2.8
37
-
38
- # synchrony
39
- - rvm: 1.8.7
40
- gemfile: .travis/Gemfile
41
- env: conn=synchrony REDIS_BRANCH=2.8
42
- - rvm: jruby-18mode
43
- gemfile: .travis/Gemfile
44
- env: conn=synchrony REDIS_BRANCH=2.8
45
- - rvm: jruby-19mode
46
- gemfile: .travis/Gemfile
47
- env: conn=synchrony REDIS_BRANCH=2.8
48
-
49
- notifications:
50
- irc:
51
- - irc.freenode.net#redis-rb
52
- email:
53
- - damian.janowski@gmail.com
54
- - pcnoordhuis@gmail.com
data/.yardopts DELETED
@@ -1,3 +0,0 @@
1
- --exclude redis/connection
2
- --exclude redis/compat
3
- --markup markdown
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- # encoding: utf-8
2
- source 'https://rubygems.org'
3
-
4
- gemspec
data/Rakefile DELETED
@@ -1,68 +0,0 @@
1
- require "rake/testtask"
2
-
3
- ENV["REDIS_BRANCH"] ||= "unstable"
4
-
5
- REDIS_DIR = File.expand_path(File.join("..", "test"), __FILE__)
6
- REDIS_CNF = File.join(REDIS_DIR, "test.conf")
7
- REDIS_PID = File.join(REDIS_DIR, "db", "redis.pid")
8
- BINARY = "tmp/redis-#{ENV["REDIS_BRANCH"]}/src/redis-server"
9
-
10
- task :default => :run
11
-
12
- desc "Run tests and manage server start/stop"
13
- task :run => [:start, :test, :stop]
14
-
15
- desc "Start the Redis server"
16
- task :start => BINARY do
17
- sh "#{BINARY} --version"
18
-
19
- redis_running = \
20
- begin
21
- File.exists?(REDIS_PID) && Process.kill(0, File.read(REDIS_PID).to_i)
22
- rescue Errno::ESRCH
23
- FileUtils.rm REDIS_PID
24
- false
25
- end
26
-
27
- unless redis_running
28
- unless system("#{BINARY} #{REDIS_CNF}")
29
- abort "could not start redis-server"
30
- end
31
- end
32
-
33
- at_exit do
34
- Rake::Task["stop"].invoke
35
- end
36
- end
37
-
38
- desc "Stop the Redis server"
39
- task :stop do
40
- if File.exists?(REDIS_PID)
41
- Process.kill "INT", File.read(REDIS_PID).to_i
42
- FileUtils.rm REDIS_PID
43
- end
44
- end
45
-
46
- desc "Clean up testing artifacts"
47
- task :clean do
48
- FileUtils.rm_f(BINARY)
49
- end
50
-
51
- file BINARY do
52
- branch = ENV.fetch("REDIS_BRANCH")
53
-
54
- sh <<-SH
55
- mkdir -p tmp;
56
- cd tmp;
57
- rm -rf redis-#{branch};
58
- wget https://github.com/antirez/redis/archive/#{branch}.tar.gz -O #{branch}.tar.gz;
59
- tar xf #{branch}.tar.gz;
60
- cd redis-#{branch};
61
- make
62
- SH
63
- end
64
-
65
- Rake::TestTask.new do |t|
66
- t.options = "-v" if $VERBOSE
67
- t.test_files = FileList["test/*_test.rb"]
68
- end
@@ -1,71 +0,0 @@
1
- # Run with
2
- #
3
- # $ ruby -Ilib benchmarking/logging.rb
4
- #
5
-
6
- begin
7
- require "bench"
8
- rescue LoadError
9
- $stderr.puts "`gem install bench` and try again."
10
- exit 1
11
- end
12
-
13
- require "redis"
14
- require "logger"
15
-
16
- def log(level, namespace = nil)
17
- logger = (namespace || Kernel).const_get(:Logger).new("/dev/null")
18
- logger.level = (namespace || Logger).const_get(level)
19
- logger
20
- end
21
-
22
- def stress(redis)
23
- redis.flushdb
24
-
25
- n = (ARGV.shift || 2000).to_i
26
-
27
- n.times do |i|
28
- key = "foo:#{i}"
29
- redis.set key, i
30
- redis.get key
31
- end
32
- end
33
-
34
- default = Redis.new
35
-
36
- logging_redises = [
37
- Redis.new(:logger => log(:DEBUG)),
38
- Redis.new(:logger => log(:INFO)),
39
- ]
40
-
41
- begin
42
- require "log4r"
43
-
44
- logging_redises += [
45
- Redis.new(:logger => log(:DEBUG, Log4r)),
46
- Redis.new(:logger => log(:INFO, Log4r)),
47
- ]
48
- rescue LoadError
49
- $stderr.puts "Log4r not installed. `gem install log4r` if you want to compare it against Ruby's Logger (spoiler: it's much faster)."
50
- end
51
-
52
- benchmark "Default options (no logger)" do
53
- stress(default)
54
- end
55
-
56
- logging_redises.each do |redis|
57
- logger = redis.client.logger
58
-
59
- case logger
60
- when Logger
61
- level = Logger::SEV_LABEL[logger.level]
62
- when Log4r::Logger
63
- level = logger.levels[logger.level]
64
- end
65
-
66
- benchmark "#{logger.class} on #{level}" do
67
- stress(redis)
68
- end
69
- end
70
-
71
- run 10
@@ -1,51 +0,0 @@
1
- require "benchmark"
2
-
3
- $:.push File.join(File.dirname(__FILE__), 'lib')
4
-
5
- require 'redis'
6
-
7
- ITERATIONS = 10000
8
-
9
- @r = Redis.new
10
-
11
- Benchmark.bmbm do |benchmark|
12
- benchmark.report("set") do
13
- @r.flushdb
14
-
15
- ITERATIONS.times do |i|
16
- @r.set("foo#{i}", "Hello world!")
17
- @r.get("foo#{i}")
18
- end
19
- end
20
-
21
- benchmark.report("set (pipelined)") do
22
- @r.flushdb
23
-
24
- @r.pipelined do
25
- ITERATIONS.times do |i|
26
- @r.set("foo#{i}", "Hello world!")
27
- @r.get("foo#{i}")
28
- end
29
- end
30
- end
31
-
32
- benchmark.report("lpush+ltrim") do
33
- @r.flushdb
34
-
35
- ITERATIONS.times do |i|
36
- @r.lpush "lpush#{i}", i
37
- @r.ltrim "ltrim#{i}", 0, 30
38
- end
39
- end
40
-
41
- benchmark.report("lpush+ltrim (pipelined)") do
42
- @r.flushdb
43
-
44
- @r.pipelined do
45
- ITERATIONS.times do |i|
46
- @r.lpush "lpush#{i}", i
47
- @r.ltrim "ltrim#{i}", 0, 30
48
- end
49
- end
50
- end
51
- end
@@ -1,21 +0,0 @@
1
- # Run with
2
- #
3
- # $ ruby -Ilib benchmarking/speed.rb
4
- #
5
-
6
- require "benchmark"
7
- require "redis"
8
-
9
- r = Redis.new
10
- n = (ARGV.shift || 20000).to_i
11
-
12
- elapsed = Benchmark.realtime do
13
- # n sets, n gets
14
- n.times do |i|
15
- key = "foo#{i}"
16
- r[key] = key * 10
17
- r[key]
18
- end
19
- end
20
-
21
- puts '%.2f Kops' % (2 * n / 1000 / elapsed)
@@ -1,24 +0,0 @@
1
- require 'fileutils'
2
-
3
- def run_in_background(command)
4
- fork { system command }
5
- end
6
-
7
- def with_all_segments(&block)
8
- 0.upto(9) do |segment_number|
9
- block_size = 100000
10
- start_index = segment_number * block_size
11
- end_index = start_index + block_size - 1
12
- block.call(start_index, end_index)
13
- end
14
- end
15
-
16
- #with_all_segments do |start_index, end_index|
17
- # puts "Initializing keys from #{start_index} to #{end_index}"
18
- # system "ruby worker.rb initialize #{start_index} #{end_index} 0"
19
- #end
20
-
21
- with_all_segments do |start_index, end_index|
22
- run_in_background "ruby worker.rb write #{start_index} #{end_index} 10"
23
- run_in_background "ruby worker.rb read #{start_index} #{end_index} 1"
24
- end
@@ -1,71 +0,0 @@
1
- BENCHMARK_ROOT = File.dirname(__FILE__)
2
- REDIS_ROOT = File.join(BENCHMARK_ROOT, "..", "lib")
3
-
4
- $: << REDIS_ROOT
5
- require 'redis'
6
- require 'benchmark'
7
-
8
- def show_usage
9
- puts <<-EOL
10
- Usage: worker.rb [read:write] <start_index> <end_index> <sleep_msec>
11
- EOL
12
- end
13
-
14
- def shift_from_argv
15
- value = ARGV.shift
16
- unless value
17
- show_usage
18
- exit -1
19
- end
20
- value
21
- end
22
-
23
- operation = shift_from_argv.to_sym
24
- start_index = shift_from_argv.to_i
25
- end_index = shift_from_argv.to_i
26
- sleep_msec = shift_from_argv.to_i
27
- sleep_duration = sleep_msec/1000.0
28
-
29
- redis = Redis.new
30
-
31
- case operation
32
- when :initialize
33
-
34
- start_index.upto(end_index) do |i|
35
- redis[i] = 0
36
- end
37
-
38
- when :clear
39
-
40
- start_index.upto(end_index) do |i|
41
- redis.delete(i)
42
- end
43
-
44
- when :read, :write
45
-
46
- puts "Starting to #{operation} at segment #{end_index + 1}"
47
-
48
- loop do
49
- t1 = Time.now
50
- start_index.upto(end_index) do |i|
51
- case operation
52
- when :read
53
- redis.get(i)
54
- when :write
55
- redis.incr(i)
56
- else
57
- raise "Unknown operation: #{operation}"
58
- end
59
- sleep sleep_duration
60
- end
61
- t2 = Time.now
62
-
63
- requests_processed = end_index - start_index
64
- time = t2 - t1
65
- puts "#{t2.strftime("%H:%M")} [segment #{end_index + 1}] : Processed #{requests_processed} requests in #{time} seconds - #{(requests_processed/time).round} requests/sec"
66
- end
67
-
68
- else
69
- raise "Unknown operation: #{operation}"
70
- end
71
-