jodosha-redis-rails 0.0.1 → 0.0.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.
- data/README.textile +2 -1
- data/Rakefile +25 -2
- data/lib/active_support/cache/redis_store.rb +1 -0
- data/lib/redis/distributed_marshaled_redis.rb +2 -0
- data/redis-rails.gemspec +3 -3
- data/spec/active_support/cache/redis_store_spec.rb +79 -41
- data/spec/config/master.conf +87 -0
- data/spec/config/single.conf +87 -0
- data/spec/config/slave.conf +87 -0
- data/spec/redis/distributed_marshaled_redis_spec.rb +6 -3
- metadata +5 -2
data/README.textile
CHANGED
@@ -18,7 +18,8 @@ h2. How to use with Rails
|
|
18
18
|
|
19
19
|
In your configuration files:
|
20
20
|
|
21
|
-
config.gem "jodosha-redis-rails", :source => "http://gems.github.com"
|
21
|
+
config.gem "jodosha-redis-rails", :source => "http://gems.github.com", :lib => "redis-rails"
|
22
|
+
require "redis-rails" # HACK Rails tries to instantiate cache first, then load configured gems
|
22
23
|
config.cache_store = :redis_store
|
23
24
|
|
24
25
|
Start Redis server, then your application.
|
data/Rakefile
CHANGED
@@ -5,7 +5,7 @@ require 'rake/testtask'
|
|
5
5
|
require 'rake/rdoctask'
|
6
6
|
require 'spec/rake/spectask'
|
7
7
|
|
8
|
-
REDIS_RAILS_VERSION = "0.0.
|
8
|
+
REDIS_RAILS_VERSION = "0.0.2"
|
9
9
|
|
10
10
|
task :default => :spec
|
11
11
|
|
@@ -26,4 +26,27 @@ desc 'Show the file list for the gemspec file'
|
|
26
26
|
task :files do
|
27
27
|
puts "Files:\n #{Dir['**/*'].reject {|f| File.directory?(f)}.sort.inspect}"
|
28
28
|
puts "Test files:\n #{Dir['spec/**/*_spec.rb'].reject {|f| File.directory?(f)}.sort.inspect}"
|
29
|
-
end
|
29
|
+
end
|
30
|
+
|
31
|
+
namespace :redis do
|
32
|
+
desc 'Start the Redis cluster'
|
33
|
+
task :start => :clean do
|
34
|
+
system "redis-server spec/config/single.conf"
|
35
|
+
system "redis-server spec/config/master.conf"
|
36
|
+
system "redis-server spec/config/slave.conf"
|
37
|
+
end
|
38
|
+
|
39
|
+
desc 'Stop the Redis cluster'
|
40
|
+
task :stop do
|
41
|
+
# TODO replace with:
|
42
|
+
# system "kill -9 `tmp/redis-single.pid`"
|
43
|
+
# system "kill -9 `tmp/redis-master.pid`"
|
44
|
+
# system "kill -9 `tmp/redis-slave.pid`"
|
45
|
+
system "ps -eo pid,comm | grep redis | xargs kill -9"
|
46
|
+
end
|
47
|
+
|
48
|
+
desc 'Clean the tmp/ directory'
|
49
|
+
task :clean do
|
50
|
+
system "rm tmp/*"
|
51
|
+
end
|
52
|
+
end
|
@@ -8,6 +8,7 @@ module ActiveSupport
|
|
8
8
|
# RedisStore.new "example.com" # => host: example.com, port: 6379, db: 0
|
9
9
|
# RedisStore.new "example.com:23682" # => host: example.com, port: 23682, db: 0
|
10
10
|
# RedisStore.new "example.com:23682/1" # => host: example.com, port: 23682, db: 1
|
11
|
+
# RedisStore.new "localhost:6379/0", "localhost:6380/0" # => instantiate a cluster
|
11
12
|
def initialize(*addresses)
|
12
13
|
addresses = extract_addresses(addresses)
|
13
14
|
@data = if addresses.size > 1
|
data/redis-rails.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "redis-rails"
|
3
|
-
s.version = "0.0.
|
4
|
-
s.date = "2009-04-
|
3
|
+
s.version = "0.0.2"
|
4
|
+
s.date = "2009-04-16"
|
5
5
|
s.summary = "Redis store for Rails"
|
6
6
|
s.author = "Luca Guidi"
|
7
7
|
s.email = "guidi.luca@gmail.com"
|
8
8
|
s.homepage = "http://lucaguidi.com"
|
9
9
|
s.description = "Redis store for Rails"
|
10
10
|
s.has_rdoc = true
|
11
|
-
s.files = ["MIT-LICENSE", "README.textile", "Rakefile", "lib/active_support/cache/redis_store.rb", "lib/redis-rails.rb", "lib/redis/distributed_marshaled_redis.rb", "lib/redis/marshaled_redis.rb", "redis-rails.gemspec", "spec/active_support/cache/redis_store_spec.rb", "spec/redis/distributed_marshaled_redis_spec.rb", "spec/redis/marshaled_redis_spec.rb", "spec/spec_helper.rb"]
|
11
|
+
s.files = ["MIT-LICENSE", "README.textile", "Rakefile", "lib/active_support/cache/redis_store.rb", "lib/redis-rails.rb", "lib/redis/distributed_marshaled_redis.rb", "lib/redis/marshaled_redis.rb", "redis-rails.gemspec", "spec/active_support/cache/redis_store_spec.rb", "spec/config/master.conf", "spec/config/single.conf", "spec/config/slave.conf", "spec/redis/distributed_marshaled_redis_spec.rb", "spec/redis/marshaled_redis_spec.rb", "spec/spec_helper.rb"]
|
12
12
|
s.test_files = ["spec/active_support/cache/redis_store_spec.rb", "spec/redis/distributed_marshaled_redis_spec.rb", "spec/redis/marshaled_redis_spec.rb"]
|
13
13
|
s.extra_rdoc_files = ["README.textile"]
|
14
14
|
end
|
@@ -5,10 +5,13 @@ module ActiveSupport
|
|
5
5
|
describe "RedisStore" do
|
6
6
|
before(:each) do
|
7
7
|
@store = RedisStore.new
|
8
|
+
@dstore = RedisStore.new "localhost:6380/1", "localhost:6381/1"
|
8
9
|
@rabbit = OpenStruct.new :name => "bunny"
|
9
10
|
@white_rabbit = OpenStruct.new :color => "white"
|
10
|
-
|
11
|
-
|
11
|
+
with_store_management do |store|
|
12
|
+
store.write "rabbit", @rabbit
|
13
|
+
store.delete "counter"
|
14
|
+
end
|
12
15
|
end
|
13
16
|
|
14
17
|
it "should accept connection params" do
|
@@ -38,12 +41,16 @@ module ActiveSupport
|
|
38
41
|
end
|
39
42
|
|
40
43
|
it "should read the data" do
|
41
|
-
|
44
|
+
with_store_management do |store|
|
45
|
+
store.read("rabbit").should === @rabbit
|
46
|
+
end
|
42
47
|
end
|
43
48
|
|
44
49
|
it "should write the data" do
|
45
|
-
|
46
|
-
|
50
|
+
with_store_management do |store|
|
51
|
+
store.write "rabbit", @white_rabbit
|
52
|
+
store.read("rabbit").should === @white_rabbit
|
53
|
+
end
|
47
54
|
end
|
48
55
|
|
49
56
|
# it "should write the data with expiration time" do
|
@@ -53,80 +60,111 @@ module ActiveSupport
|
|
53
60
|
# end
|
54
61
|
|
55
62
|
it "should not write data if :unless_exist option is true" do
|
56
|
-
|
57
|
-
|
63
|
+
with_store_management do |store|
|
64
|
+
store.write "rabbit", @white_rabbit, :unless_exist => true
|
65
|
+
store.read("rabbit").should === @rabbit
|
66
|
+
end
|
58
67
|
end
|
59
68
|
|
60
69
|
it "should read raw data" do
|
61
|
-
|
70
|
+
with_store_management do |store|
|
71
|
+
store.read("rabbit", :raw => true).should == "\004\bU:\017OpenStruct{\006:\tname\"\nbunny"
|
72
|
+
end
|
62
73
|
end
|
63
74
|
|
64
75
|
it "should write raw data" do
|
65
|
-
|
66
|
-
|
76
|
+
with_store_management do |store|
|
77
|
+
store.write "rabbit", @white_rabbit, :raw => true
|
78
|
+
store.read("rabbit", :raw => true).should == %(#<OpenStruct color="white">)
|
79
|
+
end
|
67
80
|
end
|
68
81
|
|
69
82
|
it "should delete data" do
|
70
|
-
|
71
|
-
|
83
|
+
with_store_management do |store|
|
84
|
+
store.delete "rabbit"
|
85
|
+
store.read("rabbit").should be_nil
|
86
|
+
end
|
72
87
|
end
|
73
88
|
|
74
89
|
it "should delete matched data" do
|
75
|
-
|
76
|
-
|
90
|
+
with_store_management do |store|
|
91
|
+
store.delete_matched "rabb*"
|
92
|
+
store.read("rabbit").should be_nil
|
93
|
+
end
|
77
94
|
end
|
78
95
|
|
79
96
|
it "should verify existence of an object in the store" do
|
80
|
-
|
81
|
-
|
97
|
+
with_store_management do |store|
|
98
|
+
store.exist?("rabbit").should be_true
|
99
|
+
store.exist?("rab-a-dub").should be_false
|
100
|
+
end
|
82
101
|
end
|
83
102
|
|
84
103
|
it "should increment a key" do
|
85
|
-
|
86
|
-
|
104
|
+
with_store_management do |store|
|
105
|
+
3.times { store.increment "counter" }
|
106
|
+
store.read("counter", :raw => true).to_i.should == 3
|
107
|
+
end
|
87
108
|
end
|
88
109
|
|
89
110
|
it "should decrement a key" do
|
90
|
-
|
91
|
-
|
92
|
-
|
111
|
+
with_store_management do |store|
|
112
|
+
3.times { store.increment "counter" }
|
113
|
+
2.times { store.decrement "counter" }
|
114
|
+
store.read("counter", :raw => true).to_i.should == 1
|
115
|
+
end
|
93
116
|
end
|
94
117
|
|
95
118
|
it "should increment a key by given value" do
|
96
|
-
|
97
|
-
|
119
|
+
with_store_management do |store|
|
120
|
+
store.increment "counter", 3
|
121
|
+
store.read("counter", :raw => true).to_i.should == 3
|
122
|
+
end
|
98
123
|
end
|
99
124
|
|
100
125
|
it "should decrement a key by given value" do
|
101
|
-
|
102
|
-
|
103
|
-
|
126
|
+
with_store_management do |store|
|
127
|
+
3.times { store.increment "counter" }
|
128
|
+
store.decrement "counter", 2
|
129
|
+
store.read("counter", :raw => true).to_i.should == 1
|
130
|
+
end
|
104
131
|
end
|
105
132
|
|
106
133
|
it "should clear the store" do
|
107
|
-
|
108
|
-
|
134
|
+
with_store_management do |store|
|
135
|
+
store.clear
|
136
|
+
store.instance_variable_get(:@data).keys("*").should be_empty
|
137
|
+
end
|
109
138
|
end
|
110
139
|
|
111
140
|
it "should return store stats" do
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
141
|
+
with_store_management do |store|
|
142
|
+
store.stats.should_not be_empty
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
it "should fetch data" do
|
147
|
+
with_store_management do |store|
|
148
|
+
store.fetch("rabbit").should == @rabbit
|
149
|
+
store.fetch("rub-a-dub").should be_nil
|
150
|
+
store.fetch("rub-a-dub") { "Flora de Cana" }
|
151
|
+
store.fetch("rub-a-dub").should === "Flora de Cana"
|
152
|
+
store.fetch("rabbit", :force => true).should be_nil # force cache miss
|
153
|
+
# store.fetch("rabbit", :force => true, :expires_in => 1.second) { @white_rabbit }
|
154
|
+
# store.fetch("rabbit").should === @white_rabbit ; sleep 2
|
155
|
+
# store.fetch("rabbit").should be_nil
|
156
|
+
end
|
157
|
+
end
|
125
158
|
|
126
159
|
private
|
127
160
|
def instantiate_store(address = nil)
|
128
161
|
RedisStore.new(address).instance_variable_get(:@data)
|
129
162
|
end
|
163
|
+
|
164
|
+
def with_store_management
|
165
|
+
yield @store
|
166
|
+
yield @dstore
|
167
|
+
end
|
130
168
|
end
|
131
169
|
end
|
132
170
|
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# Redis configuration file example
|
2
|
+
|
3
|
+
# By default Redis does not run as a daemon. Use 'yes' if you need it.
|
4
|
+
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
|
5
|
+
daemonize yes
|
6
|
+
|
7
|
+
# When run as a daemon, Redis write a pid file in /var/run/redis.pid by default.
|
8
|
+
# You can specify a custom pid file location here.
|
9
|
+
pidfile ./tmp/redis-master.pid
|
10
|
+
|
11
|
+
# Accept connections on the specified port, default is 6379
|
12
|
+
port 6380
|
13
|
+
|
14
|
+
# If you want you can bind a single interface, if the bind option is not
|
15
|
+
# specified all the interfaces will listen for connections.
|
16
|
+
#
|
17
|
+
# bind 127.0.0.1
|
18
|
+
|
19
|
+
# Close the connection after a client is idle for N seconds
|
20
|
+
timeout 300
|
21
|
+
|
22
|
+
# Save the DB on disk:
|
23
|
+
#
|
24
|
+
# save <seconds> <changes>
|
25
|
+
#
|
26
|
+
# Will save the DB if both the given number of seconds and the given
|
27
|
+
# number of write operations against the DB occurred.
|
28
|
+
#
|
29
|
+
# In the example below the behaviour will be to save:
|
30
|
+
# after 900 sec (15 min) if at least 1 key changed
|
31
|
+
# after 300 sec (5 min) if at least 10 keys changed
|
32
|
+
# after 60 sec if at least 10000 keys changed
|
33
|
+
save 900 1
|
34
|
+
save 300 10
|
35
|
+
save 60 10000
|
36
|
+
|
37
|
+
# For default save/load DB in/from the working directory
|
38
|
+
# Note that you must specify a directory not a file name.
|
39
|
+
dir ./tmp
|
40
|
+
|
41
|
+
# Set server verbosity to 'debug'
|
42
|
+
# it can be one of:
|
43
|
+
# debug (a lot of information, useful for development/testing)
|
44
|
+
# notice (moderately verbose, what you want in production probably)
|
45
|
+
# warning (only very important / critical messages are logged)
|
46
|
+
loglevel debug
|
47
|
+
|
48
|
+
# Specify the log file name. Also 'stdout' can be used to force
|
49
|
+
# the demon to log on the standard output. Note that if you use standard
|
50
|
+
# output for logging but daemonize, logs will be sent to /dev/null
|
51
|
+
logfile stdout
|
52
|
+
|
53
|
+
# Set the number of databases.
|
54
|
+
databases 16
|
55
|
+
|
56
|
+
################################# REPLICATION #################################
|
57
|
+
|
58
|
+
# Master-Slave replication. Use slaveof to make a Redis instance a copy of
|
59
|
+
# another Redis server. Note that the configuration is local to the slave
|
60
|
+
# so for example it is possible to configure the slave to save the DB with a
|
61
|
+
# different interval, or to listen to another port, and so on.
|
62
|
+
|
63
|
+
# slaveof <masterip> <masterport>
|
64
|
+
|
65
|
+
################################## SECURITY ###################################
|
66
|
+
|
67
|
+
# Require clients to issue AUTH <PASSWORD> before processing any other
|
68
|
+
# commands. This might be useful in environments in which you do not trust
|
69
|
+
# others with access to the host running redis-server.
|
70
|
+
#
|
71
|
+
# This should stay commented out for backward compatibility and because most
|
72
|
+
# people do not need auth (e.g. they run their own servers).
|
73
|
+
|
74
|
+
# requirepass foobared
|
75
|
+
|
76
|
+
############################### ADVANCED CONFIG ###############################
|
77
|
+
|
78
|
+
# Glue small output buffers together in order to send small replies in a
|
79
|
+
# single TCP packet. Uses a bit more CPU but most of the times it is a win
|
80
|
+
# in terms of number of queries per second. Use 'yes' if unsure.
|
81
|
+
glueoutputbuf yes
|
82
|
+
|
83
|
+
# Use object sharing. Can save a lot of memory if you have many common
|
84
|
+
# string in your dataset, but performs lookups against the shared objects
|
85
|
+
# pool so it uses more CPU and can be a bit slower. Usually it's a good
|
86
|
+
# idea.
|
87
|
+
shareobjects no
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# Redis configuration file example
|
2
|
+
|
3
|
+
# By default Redis does not run as a daemon. Use 'yes' if you need it.
|
4
|
+
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
|
5
|
+
daemonize yes
|
6
|
+
|
7
|
+
# When run as a daemon, Redis write a pid file in /var/run/redis.pid by default.
|
8
|
+
# You can specify a custom pid file location here.
|
9
|
+
pidfile ./tmp/redis-single.pid
|
10
|
+
|
11
|
+
# Accept connections on the specified port, default is 6379
|
12
|
+
port 6379
|
13
|
+
|
14
|
+
# If you want you can bind a single interface, if the bind option is not
|
15
|
+
# specified all the interfaces will listen for connections.
|
16
|
+
#
|
17
|
+
# bind 127.0.0.1
|
18
|
+
|
19
|
+
# Close the connection after a client is idle for N seconds
|
20
|
+
timeout 300
|
21
|
+
|
22
|
+
# Save the DB on disk:
|
23
|
+
#
|
24
|
+
# save <seconds> <changes>
|
25
|
+
#
|
26
|
+
# Will save the DB if both the given number of seconds and the given
|
27
|
+
# number of write operations against the DB occurred.
|
28
|
+
#
|
29
|
+
# In the example below the behaviour will be to save:
|
30
|
+
# after 900 sec (15 min) if at least 1 key changed
|
31
|
+
# after 300 sec (5 min) if at least 10 keys changed
|
32
|
+
# after 60 sec if at least 10000 keys changed
|
33
|
+
save 900 1
|
34
|
+
save 300 10
|
35
|
+
save 60 10000
|
36
|
+
|
37
|
+
# For default save/load DB in/from the working directory
|
38
|
+
# Note that you must specify a directory not a file name.
|
39
|
+
dir ./tmp
|
40
|
+
|
41
|
+
# Set server verbosity to 'debug'
|
42
|
+
# it can be one of:
|
43
|
+
# debug (a lot of information, useful for development/testing)
|
44
|
+
# notice (moderately verbose, what you want in production probably)
|
45
|
+
# warning (only very important / critical messages are logged)
|
46
|
+
loglevel debug
|
47
|
+
|
48
|
+
# Specify the log file name. Also 'stdout' can be used to force
|
49
|
+
# the demon to log on the standard output. Note that if you use standard
|
50
|
+
# output for logging but daemonize, logs will be sent to /dev/null
|
51
|
+
logfile stdout
|
52
|
+
|
53
|
+
# Set the number of databases.
|
54
|
+
databases 16
|
55
|
+
|
56
|
+
################################# REPLICATION #################################
|
57
|
+
|
58
|
+
# Master-Slave replication. Use slaveof to make a Redis instance a copy of
|
59
|
+
# another Redis server. Note that the configuration is local to the slave
|
60
|
+
# so for example it is possible to configure the slave to save the DB with a
|
61
|
+
# different interval, or to listen to another port, and so on.
|
62
|
+
|
63
|
+
# slaveof <masterip> <masterport>
|
64
|
+
|
65
|
+
################################## SECURITY ###################################
|
66
|
+
|
67
|
+
# Require clients to issue AUTH <PASSWORD> before processing any other
|
68
|
+
# commands. This might be useful in environments in which you do not trust
|
69
|
+
# others with access to the host running redis-server.
|
70
|
+
#
|
71
|
+
# This should stay commented out for backward compatibility and because most
|
72
|
+
# people do not need auth (e.g. they run their own servers).
|
73
|
+
|
74
|
+
# requirepass foobared
|
75
|
+
|
76
|
+
############################### ADVANCED CONFIG ###############################
|
77
|
+
|
78
|
+
# Glue small output buffers together in order to send small replies in a
|
79
|
+
# single TCP packet. Uses a bit more CPU but most of the times it is a win
|
80
|
+
# in terms of number of queries per second. Use 'yes' if unsure.
|
81
|
+
glueoutputbuf yes
|
82
|
+
|
83
|
+
# Use object sharing. Can save a lot of memory if you have many common
|
84
|
+
# string in your dataset, but performs lookups against the shared objects
|
85
|
+
# pool so it uses more CPU and can be a bit slower. Usually it's a good
|
86
|
+
# idea.
|
87
|
+
shareobjects no
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# Redis configuration file example
|
2
|
+
|
3
|
+
# By default Redis does not run as a daemon. Use 'yes' if you need it.
|
4
|
+
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
|
5
|
+
daemonize yes
|
6
|
+
|
7
|
+
# When run as a daemon, Redis write a pid file in /var/run/redis.pid by default.
|
8
|
+
# You can specify a custom pid file location here.
|
9
|
+
pidfile ./tmp/redis-slave.pid
|
10
|
+
|
11
|
+
# Accept connections on the specified port, default is 6379
|
12
|
+
port 6381
|
13
|
+
|
14
|
+
# If you want you can bind a single interface, if the bind option is not
|
15
|
+
# specified all the interfaces will listen for connections.
|
16
|
+
#
|
17
|
+
# bind 127.0.0.1
|
18
|
+
|
19
|
+
# Close the connection after a client is idle for N seconds
|
20
|
+
timeout 300
|
21
|
+
|
22
|
+
# Save the DB on disk:
|
23
|
+
#
|
24
|
+
# save <seconds> <changes>
|
25
|
+
#
|
26
|
+
# Will save the DB if both the given number of seconds and the given
|
27
|
+
# number of write operations against the DB occurred.
|
28
|
+
#
|
29
|
+
# In the example below the behaviour will be to save:
|
30
|
+
# after 900 sec (15 min) if at least 1 key changed
|
31
|
+
# after 300 sec (5 min) if at least 10 keys changed
|
32
|
+
# after 60 sec if at least 10000 keys changed
|
33
|
+
save 900 1
|
34
|
+
save 300 10
|
35
|
+
save 60 10000
|
36
|
+
|
37
|
+
# For default save/load DB in/from the working directory
|
38
|
+
# Note that you must specify a directory not a file name.
|
39
|
+
dir ./tmp
|
40
|
+
|
41
|
+
# Set server verbosity to 'debug'
|
42
|
+
# it can be one of:
|
43
|
+
# debug (a lot of information, useful for development/testing)
|
44
|
+
# notice (moderately verbose, what you want in production probably)
|
45
|
+
# warning (only very important / critical messages are logged)
|
46
|
+
loglevel debug
|
47
|
+
|
48
|
+
# Specify the log file name. Also 'stdout' can be used to force
|
49
|
+
# the demon to log on the standard output. Note that if you use standard
|
50
|
+
# output for logging but daemonize, logs will be sent to /dev/null
|
51
|
+
logfile stdout
|
52
|
+
|
53
|
+
# Set the number of databases.
|
54
|
+
databases 16
|
55
|
+
|
56
|
+
################################# REPLICATION #################################
|
57
|
+
|
58
|
+
# Master-Slave replication. Use slaveof to make a Redis instance a copy of
|
59
|
+
# another Redis server. Note that the configuration is local to the slave
|
60
|
+
# so for example it is possible to configure the slave to save the DB with a
|
61
|
+
# different interval, or to listen to another port, and so on.
|
62
|
+
|
63
|
+
# slaveof 127.0.0.1 6380
|
64
|
+
|
65
|
+
################################## SECURITY ###################################
|
66
|
+
|
67
|
+
# Require clients to issue AUTH <PASSWORD> before processing any other
|
68
|
+
# commands. This might be useful in environments in which you do not trust
|
69
|
+
# others with access to the host running redis-server.
|
70
|
+
#
|
71
|
+
# This should stay commented out for backward compatibility and because most
|
72
|
+
# people do not need auth (e.g. they run their own servers).
|
73
|
+
|
74
|
+
# requirepass foobared
|
75
|
+
|
76
|
+
############################### ADVANCED CONFIG ###############################
|
77
|
+
|
78
|
+
# Glue small output buffers together in order to send small replies in a
|
79
|
+
# single TCP packet. Uses a bit more CPU but most of the times it is a win
|
80
|
+
# in terms of number of queries per second. Use 'yes' if unsure.
|
81
|
+
glueoutputbuf yes
|
82
|
+
|
83
|
+
# Use object sharing. Can save a lot of memory if you have many common
|
84
|
+
# string in your dataset, but performs lookups against the shared objects
|
85
|
+
# pool so it uses more CPU and can be a bit slower. Usually it's a good
|
86
|
+
# idea.
|
87
|
+
shareobjects no
|
@@ -2,7 +2,10 @@ require File.join(File.dirname(__FILE__), "/../spec_helper")
|
|
2
2
|
|
3
3
|
describe "DistributedMarshaledRedis" do
|
4
4
|
before(:each) do
|
5
|
-
@dmr = DistributedMarshaledRedis.new [
|
5
|
+
@dmr = DistributedMarshaledRedis.new [
|
6
|
+
{:host => "localhost", :port => "6380", :db => 0},
|
7
|
+
{:host => "localhost", :port => "6381", :db => 0}
|
8
|
+
]
|
6
9
|
@rabbit = OpenStruct.new :name => "bunny"
|
7
10
|
@white_rabbit = OpenStruct.new :color => "white"
|
8
11
|
@dmr.set "rabbit", @rabbit
|
@@ -13,11 +16,11 @@ describe "DistributedMarshaledRedis" do
|
|
13
16
|
end
|
14
17
|
|
15
18
|
it "should accept connection params" do
|
16
|
-
dmr = DistributedMarshaledRedis.new [ :host => "redis.com", :port => "
|
19
|
+
dmr = DistributedMarshaledRedis.new [ :host => "redis.com", :port => "6380", :db => 1 ]
|
17
20
|
dmr.ring.should have(1).node
|
18
21
|
mr = dmr.ring.nodes.first
|
19
22
|
mr.host.should == "redis.com"
|
20
|
-
mr.port.should == "
|
23
|
+
mr.port.should == "6380"
|
21
24
|
mr.instance_variable_get(:@db).should == 1
|
22
25
|
end
|
23
26
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jodosha-redis-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luca Guidi
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-04-
|
12
|
+
date: 2009-04-16 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -31,6 +31,9 @@ files:
|
|
31
31
|
- lib/redis/marshaled_redis.rb
|
32
32
|
- redis-rails.gemspec
|
33
33
|
- spec/active_support/cache/redis_store_spec.rb
|
34
|
+
- spec/config/master.conf
|
35
|
+
- spec/config/single.conf
|
36
|
+
- spec/config/slave.conf
|
34
37
|
- spec/redis/distributed_marshaled_redis_spec.rb
|
35
38
|
- spec/redis/marshaled_redis_spec.rb
|
36
39
|
- spec/spec_helper.rb
|