redis-store 1.0.0.beta4 → 1.0.0.beta5

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.

Potentially problematic release.


This version of redis-store might be problematic. Click here for more details.

@@ -20,7 +20,8 @@ daemonize no
20
20
  # default. You can specify a custom pid file location here.
21
21
  pidfile /var/run/redis.pid
22
22
 
23
- # Accept connections on the specified port, default is 6379
23
+ # Accept connections on the specified port, default is 6379.
24
+ # If port 0 is specified Redis will not listen on a TCP socket.
24
25
  port 6381
25
26
 
26
27
  # If you want you can bind a single interface, if the bind option is not
@@ -28,6 +29,12 @@ port 6381
28
29
  #
29
30
  # bind 127.0.0.1
30
31
 
32
+ # Specify the path for the unix socket that will be used to listen for
33
+ # incoming connections. There is no default, so Redis will not listen
34
+ # on a unix socket when not specified.
35
+ #
36
+ # unixsocket /tmp/redis.sock
37
+
31
38
  # Close the connection after a client is idle for N seconds (0 to disable)
32
39
  timeout 300
33
40
 
@@ -37,13 +44,23 @@ timeout 300
37
44
  # verbose (many rarely useful info, but not a mess like the debug level)
38
45
  # notice (moderately verbose, what you want in production probably)
39
46
  # warning (only very important / critical messages are logged)
40
- loglevel debug
47
+ loglevel verbose
41
48
 
42
49
  # Specify the log file name. Also 'stdout' can be used to force
43
50
  # Redis to log on the standard output. Note that if you use standard
44
51
  # output for logging but daemonize, logs will be sent to /dev/null
45
52
  logfile stdout
46
53
 
54
+ # To enable logging to the system logger, just set 'syslog-enabled' to yes,
55
+ # and optionally update the other syslog parameters to suit your needs.
56
+ # syslog-enabled no
57
+
58
+ # Specify the syslog identity.
59
+ # syslog-ident redis
60
+
61
+ # Specify the syslog facility. Must be USER or between LOCAL0-LOCAL7.
62
+ # syslog-facility local0
63
+
47
64
  # Set the number of databases. The default database is DB 0, you can select
48
65
  # a different one on a per-connection basis using SELECT <dbid> where
49
66
  # dbid is a number between 0 and 'databases'-1
@@ -76,7 +93,7 @@ save 60 10000
76
93
  rdbcompression yes
77
94
 
78
95
  # The filename where to dump the DB
79
- dbfilename tmp/slave-dump.rdb
96
+ dbfilename tmp/node-two-dump.rdb
80
97
 
81
98
  # The working directory.
82
99
  #
@@ -95,7 +112,7 @@ dir ./
95
112
  # so for example it is possible to configure the slave to save the DB with a
96
113
  # different interval, or to listen to another port, and so on.
97
114
  #
98
- slaveof 127.0.0.1 6380
115
+ # slaveof 127.0.0.1 6380
99
116
 
100
117
  # If the master is password protected (using the "requirepass" configuration
101
118
  # directive below) it is possible to tell the slave to authenticate before
@@ -104,6 +121,19 @@ slaveof 127.0.0.1 6380
104
121
  #
105
122
  # masterauth <master-password>
106
123
 
124
+ # When a slave lost the connection with the master, or when the replication
125
+ # is still in progress, the slave can act in two different ways:
126
+ #
127
+ # 1) if slave-serve-stale-data is set to 'yes' (the default) the slave will
128
+ # still reply to client requests, possibly with out of data data, or the
129
+ # data set may just be empty if this is the first synchronization.
130
+ #
131
+ # 2) if slave-serve-stale data is set to 'no' the slave will reply with
132
+ # an error "SYNC with master in progress" to all the kind of commands
133
+ # but to INFO and SLAVEOF.
134
+ #
135
+ slave-serve-stale-data yes
136
+
107
137
  ################################## SECURITY ###################################
108
138
 
109
139
  # Require clients to issue AUTH <PASSWORD> before processing any other
@@ -119,6 +149,22 @@ slaveof 127.0.0.1 6380
119
149
  #
120
150
  # requirepass foobared
121
151
 
152
+ # Command renaming.
153
+ #
154
+ # It is possilbe to change the name of dangerous commands in a shared
155
+ # environment. For instance the CONFIG command may be renamed into something
156
+ # of hard to guess so that it will be still available for internal-use
157
+ # tools but not available for general clients.
158
+ #
159
+ # Example:
160
+ #
161
+ # rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52
162
+ #
163
+ # It is also possilbe to completely kill a command renaming it into
164
+ # an empty string:
165
+ #
166
+ # rename-command CONFIG ""
167
+
122
168
  ################################### LIMITS ####################################
123
169
 
124
170
  # Set the max number of connected clients at the same time. By default there
@@ -148,6 +194,37 @@ slaveof 127.0.0.1 6380
148
194
  #
149
195
  # maxmemory <bytes>
150
196
 
197
+ # MAXMEMORY POLICY: how Redis will select what to remove when maxmemory
198
+ # is reached? You can select among five behavior:
199
+ #
200
+ # volatile-lru -> remove the key with an expire set using an LRU algorithm
201
+ # allkeys-lru -> remove any key accordingly to the LRU algorithm
202
+ # volatile-random -> remove a random key with an expire set
203
+ # allkeys->random -> remove a random key, any key
204
+ # volatile-ttl -> remove the key with the nearest expire time (minor TTL)
205
+ # noeviction -> don't expire at all, just return an error on write operations
206
+ #
207
+ # Note: with all the kind of policies, Redis will return an error on write
208
+ # operations, when there are not suitable keys for eviction.
209
+ #
210
+ # At the date of writing this commands are: set setnx setex append
211
+ # incr decr rpush lpush rpushx lpushx linsert lset rpoplpush sadd
212
+ # sinter sinterstore sunion sunionstore sdiff sdiffstore zadd zincrby
213
+ # zunionstore zinterstore hset hsetnx hmset hincrby incrby decrby
214
+ # getset mset msetnx exec sort
215
+ #
216
+ # The default is:
217
+ #
218
+ # maxmemory-policy volatile-lru
219
+
220
+ # LRU and minimal TTL algorithms are not precise algorithms but approximated
221
+ # algorithms (in order to save memory), so you can select as well the sample
222
+ # size to check. For instance for default Redis will check three keys and
223
+ # pick the one that was used less recently, you can change the sample size
224
+ # using the following configuration directive.
225
+ #
226
+ # maxmemory-samples 3
227
+
151
228
  ############################## APPEND ONLY MODE ###############################
152
229
 
153
230
  # By default Redis asynchronously dumps the dataset on disk. If you can live
@@ -195,6 +272,26 @@ appendonly no
195
272
  appendfsync everysec
196
273
  # appendfsync no
197
274
 
275
+ # When the AOF fsync policy is set to always or everysec, and a background
276
+ # saving process (a background save or AOF log background rewriting) is
277
+ # performing a lot of I/O against the disk, in some Linux configurations
278
+ # Redis may block too long on the fsync() call. Note that there is no fix for
279
+ # this currently, as even performing fsync in a different thread will block
280
+ # our synchronous write(2) call.
281
+ #
282
+ # In order to mitigate this problem it's possible to use the following option
283
+ # that will prevent fsync() from being called in the main process while a
284
+ # BGSAVE or BGREWRITEAOF is in progress.
285
+ #
286
+ # This means that while another child is saving the durability of Redis is
287
+ # the same as "appendfsync none", that in pratical terms means that it is
288
+ # possible to lost up to 30 seconds of log in the worst scenario (with the
289
+ # default Linux settings).
290
+ #
291
+ # If you have latency problems turn this to "yes". Otherwise leave it as
292
+ # "no" that is the safest pick from the point of view of durability.
293
+ no-appendfsync-on-rewrite no
294
+
198
295
  ################################ VIRTUAL MEMORY ###############################
199
296
 
200
297
  # Virtual Memory allows Redis to work with datasets bigger than the actual
@@ -269,17 +366,25 @@ vm-max-threads 4
269
366
 
270
367
  ############################### ADVANCED CONFIG ###############################
271
368
 
272
- # Glue small output buffers together in order to send small replies in a
273
- # single TCP packet. Uses a bit more CPU but most of the times it is a win
274
- # in terms of number of queries per second. Use 'yes' if unsure.
275
- glueoutputbuf yes
276
-
277
369
  # Hashes are encoded in a special way (much more memory efficient) when they
278
370
  # have at max a given numer of elements, and the biggest element does not
279
371
  # exceed a given threshold. You can configure this limits with the following
280
372
  # configuration directives.
281
- hash-max-zipmap-entries 64
282
- hash-max-zipmap-value 512
373
+ hash-max-zipmap-entries 512
374
+ hash-max-zipmap-value 64
375
+
376
+ # Similarly to hashes, small lists are also encoded in a special way in order
377
+ # to save a lot of space. The special representation is only used when
378
+ # you are under the following limits:
379
+ list-max-ziplist-entries 512
380
+ list-max-ziplist-value 64
381
+
382
+ # Sets have a special encoding in just one case: when a set is composed
383
+ # of just strings that happens to be integers in radix 10 in the range
384
+ # of 64 bit signed integers.
385
+ # The following configuration setting sets the limit in the size of the
386
+ # set in order to use this special memory saving encoding.
387
+ set-max-intset-entries 512
283
388
 
284
389
  # Active rehashing uses 1 millisecond every 100 milliseconds of CPU time in
285
390
  # order to help rehashing the main Redis hash table (the one mapping top-level
@@ -20,7 +20,8 @@ daemonize no
20
20
  # default. You can specify a custom pid file location here.
21
21
  pidfile /var/run/redis.pid
22
22
 
23
- # Accept connections on the specified port, default is 6379
23
+ # Accept connections on the specified port, default is 6379.
24
+ # If port 0 is specified Redis will not listen on a TCP socket.
24
25
  port 6379
25
26
 
26
27
  # If you want you can bind a single interface, if the bind option is not
@@ -28,6 +29,12 @@ port 6379
28
29
  #
29
30
  # bind 127.0.0.1
30
31
 
32
+ # Specify the path for the unix socket that will be used to listen for
33
+ # incoming connections. There is no default, so Redis will not listen
34
+ # on a unix socket when not specified.
35
+ #
36
+ # unixsocket /tmp/redis.sock
37
+
31
38
  # Close the connection after a client is idle for N seconds (0 to disable)
32
39
  timeout 300
33
40
 
@@ -37,13 +44,23 @@ timeout 300
37
44
  # verbose (many rarely useful info, but not a mess like the debug level)
38
45
  # notice (moderately verbose, what you want in production probably)
39
46
  # warning (only very important / critical messages are logged)
40
- loglevel debug
47
+ loglevel verbose
41
48
 
42
49
  # Specify the log file name. Also 'stdout' can be used to force
43
50
  # Redis to log on the standard output. Note that if you use standard
44
51
  # output for logging but daemonize, logs will be sent to /dev/null
45
52
  logfile stdout
46
53
 
54
+ # To enable logging to the system logger, just set 'syslog-enabled' to yes,
55
+ # and optionally update the other syslog parameters to suit your needs.
56
+ # syslog-enabled no
57
+
58
+ # Specify the syslog identity.
59
+ # syslog-ident redis
60
+
61
+ # Specify the syslog facility. Must be USER or between LOCAL0-LOCAL7.
62
+ # syslog-facility local0
63
+
47
64
  # Set the number of databases. The default database is DB 0, you can select
48
65
  # a different one on a per-connection basis using SELECT <dbid> where
49
66
  # dbid is a number between 0 and 'databases'-1
@@ -104,6 +121,19 @@ dir ./
104
121
  #
105
122
  # masterauth <master-password>
106
123
 
124
+ # When a slave lost the connection with the master, or when the replication
125
+ # is still in progress, the slave can act in two different ways:
126
+ #
127
+ # 1) if slave-serve-stale-data is set to 'yes' (the default) the slave will
128
+ # still reply to client requests, possibly with out of data data, or the
129
+ # data set may just be empty if this is the first synchronization.
130
+ #
131
+ # 2) if slave-serve-stale data is set to 'no' the slave will reply with
132
+ # an error "SYNC with master in progress" to all the kind of commands
133
+ # but to INFO and SLAVEOF.
134
+ #
135
+ slave-serve-stale-data yes
136
+
107
137
  ################################## SECURITY ###################################
108
138
 
109
139
  # Require clients to issue AUTH <PASSWORD> before processing any other
@@ -119,6 +149,22 @@ dir ./
119
149
  #
120
150
  # requirepass foobared
121
151
 
152
+ # Command renaming.
153
+ #
154
+ # It is possilbe to change the name of dangerous commands in a shared
155
+ # environment. For instance the CONFIG command may be renamed into something
156
+ # of hard to guess so that it will be still available for internal-use
157
+ # tools but not available for general clients.
158
+ #
159
+ # Example:
160
+ #
161
+ # rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52
162
+ #
163
+ # It is also possilbe to completely kill a command renaming it into
164
+ # an empty string:
165
+ #
166
+ # rename-command CONFIG ""
167
+
122
168
  ################################### LIMITS ####################################
123
169
 
124
170
  # Set the max number of connected clients at the same time. By default there
@@ -148,6 +194,37 @@ dir ./
148
194
  #
149
195
  # maxmemory <bytes>
150
196
 
197
+ # MAXMEMORY POLICY: how Redis will select what to remove when maxmemory
198
+ # is reached? You can select among five behavior:
199
+ #
200
+ # volatile-lru -> remove the key with an expire set using an LRU algorithm
201
+ # allkeys-lru -> remove any key accordingly to the LRU algorithm
202
+ # volatile-random -> remove a random key with an expire set
203
+ # allkeys->random -> remove a random key, any key
204
+ # volatile-ttl -> remove the key with the nearest expire time (minor TTL)
205
+ # noeviction -> don't expire at all, just return an error on write operations
206
+ #
207
+ # Note: with all the kind of policies, Redis will return an error on write
208
+ # operations, when there are not suitable keys for eviction.
209
+ #
210
+ # At the date of writing this commands are: set setnx setex append
211
+ # incr decr rpush lpush rpushx lpushx linsert lset rpoplpush sadd
212
+ # sinter sinterstore sunion sunionstore sdiff sdiffstore zadd zincrby
213
+ # zunionstore zinterstore hset hsetnx hmset hincrby incrby decrby
214
+ # getset mset msetnx exec sort
215
+ #
216
+ # The default is:
217
+ #
218
+ # maxmemory-policy volatile-lru
219
+
220
+ # LRU and minimal TTL algorithms are not precise algorithms but approximated
221
+ # algorithms (in order to save memory), so you can select as well the sample
222
+ # size to check. For instance for default Redis will check three keys and
223
+ # pick the one that was used less recently, you can change the sample size
224
+ # using the following configuration directive.
225
+ #
226
+ # maxmemory-samples 3
227
+
151
228
  ############################## APPEND ONLY MODE ###############################
152
229
 
153
230
  # By default Redis asynchronously dumps the dataset on disk. If you can live
@@ -195,6 +272,26 @@ appendonly no
195
272
  appendfsync everysec
196
273
  # appendfsync no
197
274
 
275
+ # When the AOF fsync policy is set to always or everysec, and a background
276
+ # saving process (a background save or AOF log background rewriting) is
277
+ # performing a lot of I/O against the disk, in some Linux configurations
278
+ # Redis may block too long on the fsync() call. Note that there is no fix for
279
+ # this currently, as even performing fsync in a different thread will block
280
+ # our synchronous write(2) call.
281
+ #
282
+ # In order to mitigate this problem it's possible to use the following option
283
+ # that will prevent fsync() from being called in the main process while a
284
+ # BGSAVE or BGREWRITEAOF is in progress.
285
+ #
286
+ # This means that while another child is saving the durability of Redis is
287
+ # the same as "appendfsync none", that in pratical terms means that it is
288
+ # possible to lost up to 30 seconds of log in the worst scenario (with the
289
+ # default Linux settings).
290
+ #
291
+ # If you have latency problems turn this to "yes". Otherwise leave it as
292
+ # "no" that is the safest pick from the point of view of durability.
293
+ no-appendfsync-on-rewrite no
294
+
198
295
  ################################ VIRTUAL MEMORY ###############################
199
296
 
200
297
  # Virtual Memory allows Redis to work with datasets bigger than the actual
@@ -269,17 +366,25 @@ vm-max-threads 4
269
366
 
270
367
  ############################### ADVANCED CONFIG ###############################
271
368
 
272
- # Glue small output buffers together in order to send small replies in a
273
- # single TCP packet. Uses a bit more CPU but most of the times it is a win
274
- # in terms of number of queries per second. Use 'yes' if unsure.
275
- glueoutputbuf yes
276
-
277
369
  # Hashes are encoded in a special way (much more memory efficient) when they
278
370
  # have at max a given numer of elements, and the biggest element does not
279
371
  # exceed a given threshold. You can configure this limits with the following
280
372
  # configuration directives.
281
- hash-max-zipmap-entries 64
282
- hash-max-zipmap-value 512
373
+ hash-max-zipmap-entries 512
374
+ hash-max-zipmap-value 64
375
+
376
+ # Similarly to hashes, small lists are also encoded in a special way in order
377
+ # to save a lot of space. The special representation is only used when
378
+ # you are under the following limits:
379
+ list-max-ziplist-entries 512
380
+ list-max-ziplist-value 64
381
+
382
+ # Sets have a special encoding in just one case: when a set is composed
383
+ # of just strings that happens to be integers in radix 10 in the range
384
+ # of 64 bit signed integers.
385
+ # The following configuration setting sets the limit in the size of the
386
+ # set in order to use this special memory saving encoding.
387
+ set-max-intset-entries 512
283
388
 
284
389
  # Active rehashing uses 1 millisecond every 100 milliseconds of CPU time in
285
390
  # order to help rehashing the main Redis hash table (the one mapping top-level
@@ -44,13 +44,29 @@ describe "I18n::Backend::Redis" do
44
44
  lambda { I18n.backend.store_translations :en, :foo => lambda {|| } }.should raise_error("Key-value stores cannot handle procs")
45
45
  end
46
46
 
47
- it "should list available locales" do
48
- locales = [ :en, :it, :es, :fr, :de ]
49
- locales.each { |locale| I18n.backend.store_translations locale, :foo => "bar" }
50
- available_locales = I18n.backend.available_locales
47
+ describe "available locales" do
48
+ before :each do
49
+ @locales = [ :en, :it, :es, :fr, :de ]
50
+ end
51
+
52
+ it "should list" do
53
+ @locales.each { |locale| I18n.backend.store_translations locale, :foo => "bar" }
54
+ available_locales = I18n.backend.available_locales
55
+
56
+ @locales.each do |locale|
57
+ available_locales.should include(locale)
58
+ end
59
+ end
60
+
61
+ it "should list when namespaced" do
62
+ I18n.backend = I18n::Backend::Redis.new :namespace => 'foo'
63
+
64
+ @locales.each { |locale| I18n.backend.store_translations locale, :foo => "bar" }
65
+ available_locales = I18n.backend.available_locales
51
66
 
52
- locales.each do |locale|
53
- available_locales.should include(locale)
67
+ @locales.each do |locale|
68
+ available_locales.should include(locale)
69
+ end
54
70
  end
55
71
  end
56
72
  end
@@ -22,6 +22,14 @@ describe "Redis::DistributedStore" do
22
22
  mr.to_s.should == "Redis Client connected to localhost:6380 against DB 1"
23
23
  end
24
24
 
25
+ it "should force reconnection" do
26
+ @dmr.nodes.each do |node|
27
+ node.should_receive(:reconnect)
28
+ end
29
+
30
+ @dmr.reconnect
31
+ end
32
+
25
33
  it "should set an object" do
26
34
  @dmr.set "rabbit", @white_rabbit
27
35
  @dmr.get("rabbit").should == @white_rabbit
@@ -50,8 +50,8 @@ describe "Redis::Store::Namespace" do
50
50
  end
51
51
 
52
52
  it "should namespace keys" do
53
- @client.should_receive(:call).with(:keys, "#{@namespace}:rabb*").and_return [ "#{@namespace}:rabbit" ]
54
- @store.keys "rabb*"
53
+ @store.set "rabbit", @rabbit
54
+ @store.keys("rabb*").should == [ "rabbit" ]
55
55
  end
56
56
 
57
57
  it "should namespace exists" do