redis-store 1.0.0.beta1 → 1.0.0.beta2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


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

@@ -0,0 +1,211 @@
1
+ *1.0.0 [beta2] (June 12, 2010)*
2
+
3
+ * Bump version v1.0.0.beta2
4
+ * Added committers names to CHANGELOG
5
+ * Added CHANGELOG
6
+ * Rake namespace: redis_cluster => redis:cluster
7
+ * Fixed Rails 3 failing spec
8
+ * Added ActiveSupport
9
+ * Enabled notifications for ActiveSupport
10
+ * Moved spec
11
+ * Use consinstent Rails 3 check in session store
12
+ * Make sure of use top-level module
13
+ * Updated Rails 2.x development dependencies
14
+
15
+ *1.0.0 [beta1] (June 10, 2010)*
16
+
17
+ * Bump version v1.0.0.beta1
18
+ * Made specs pass for Ruby 1.9.1
19
+ * Updated instructions to test against Rails 3.x
20
+ * Updated copyright year
21
+ * Prepare for v1.0.0.beta1
22
+ * Use Rails v3.0.0.beta4
23
+ * Require redis >= 2.0.0 gem in Gemfile
24
+ * Updated instructions for Rails 2 session store
25
+ * Added instructions for Rails 3 configuration
26
+ * Check against Rails#version instead of Rails
27
+ * Added redis gem as dependency
28
+ * Changed spec_helper.rb according to the new Rails 3 check
29
+ * Fix the rails3 check [Bruno Michel]
30
+ * Added bundler cleanup Rake task
31
+ * Fixed ActiveSupport
32
+ * Re-enabled redis:console Rake task
33
+ * Don't use Rspec#have with ActiveSupport 3
34
+ * Fixed Rails 2 regression for ActiveSupport
35
+ * Fixed issues for ActiveSupport
36
+ * Rails 3 namespace
37
+ * Use Rails edge instead of 3.0.0.beta3
38
+ * Made the specs run again
39
+ * Updated Gemfile development/test dependecies for rails3.
40
+ * Updated README instructions
41
+ * Updated test configuration files, according to redis-2.0.0-rc1 defaults
42
+ * Made specs pass with redis-2.0.0 gem
43
+ * Don't support the old redis-rb namespace
44
+ * Import the whole redis-rb old Rake tasks
45
+ * Updated redis-rb dependency
46
+
47
+ *0.3.8 [Final] (May 21, 2010)*
48
+
49
+ * Fixed gemspec executable issue
50
+ * Updated .gemspec
51
+ * Version bump to 0.3.8
52
+ * Started namespace migration for redis-2.0.0
53
+ * Merge branch 'master' of http://github.com/akahn/redis-store
54
+ * Fixed dependency issues. [Brian Takita]
55
+ * Removed methodpara because it require ruby 1.9.1. [Brian Takita]
56
+ * Merge branch 'master' of http://github.com/dsander/redis-store [Brian Takita]
57
+ * Moved RedisSessionStore to rack session directory. [Brian Takita]
58
+ * Got RedisSessionStore working with passing specs. [Brian Takita]
59
+ * Using modified version of RedisSessionStore (http://github.com/mattmatt/redis-session-store). Still needs testing. [Brian Takita]
60
+ * Using redis 1.0.5. [Brian Takita]
61
+ * Ignoring gem files and gemspecs with a prefix. [Brian Takita]
62
+ * Added git and jeweler to dependencies. [Brian Takita]
63
+ * Ignoring .bundle and rubymine files. [Brian Takita]
64
+ * Added ability to add a prefix to the gem name via the GEM_PREFIX environment variable. [Brian Takita]
65
+ * Fixed marshalling issues with the new Redis api. Fixed redis-server configurations for the latest version of redis-server. Added redis_cluster:start and redis_cluster:stop rake tasks. Spec suite passes. [Brian Takita]
66
+ * Fixed redis deprecation warnings. [Brian Takita]
67
+ * Using redis 1.0.4. Loading redis.tasks.rb from redis gem using Bundler. Fixed redis test configurations. [Brian Takita]
68
+ * Supports redis 1.0.5 [Dominik Sander]
69
+ * Add Rack [Alexander Kahn]
70
+ * Updated development and testing dependencies
71
+ * Made compatible with rack-cache-0.5.2
72
+
73
+ *0.3.7 [Final] (November 15, 2009)*
74
+
75
+ * Version bump to 0.3.7
76
+ * Version bump to 0.3.7
77
+ * Updated spec instructions in README
78
+ * Jeweler generated redis-store.gemspec
79
+ * Removed no longer used Rake tasks. Added Gemcutter support via Jeweler.
80
+ * Typo
81
+ * Let Rcov task run with the Redis cluster started
82
+ * Make spec suite pass again
83
+ * README.textile -> README.md
84
+ * Re-enabled Merb specs
85
+ * Added *.rdb in .gitignore
86
+ * Run detached Redis instances for spec suite
87
+ * Start detached Redis server for specs
88
+ * Added Gemfile, removed rubygems dependecy for testing.
89
+ * Added *.swp to .gitignore
90
+ * Added jeweler rake tasks
91
+ * Make it work in classic Sinatra apps. [Dmitriy Timokhin]
92
+ * Updated README with new instructions about redis-rb
93
+
94
+ *0.3.6 [Final] (June 18, 2009)*
95
+
96
+ * Prepare for v0.3.6
97
+ * Updated README with new version
98
+ * Changed Redis config files for specs
99
+ * Updated README instructions
100
+ * New filelist in gemspec
101
+ * Fixed typo in spec
102
+ * Don't try to unmarshal empty strings
103
+ * Running specs according to the DEBUG env var
104
+ * Added specs for uncovered Merb Cache API
105
+ * Added rcov Rake task
106
+ * Fix README
107
+ * Fix typo in README
108
+ * Updated README instructions
109
+ * Removed RedisError catching
110
+ * Declaring for now RedisError in spec_helper.rb
111
+ * Removed unnecessary classes
112
+ * Fix specs for DistributedMarshaledRedis
113
+ * Fix some specs
114
+ * Made Server#notify_observers private
115
+ * Ensure to select the correct database after the socket connection
116
+ * Reverted socket pooling. Ensure to always return an active socket.
117
+ * Lowering default timeout from 10 to 0.1
118
+
119
+ *0.3.5 [Final] (May 7, 2009)*
120
+
121
+ * Prepare for v0.3.5
122
+ * Totally replace ezmobius-redis-rb Server implementation
123
+ * Fixed default Server timeout to 1 second
124
+ * Little refactoring
125
+ * Ensure Server#active? always returns a boolean and never raise an exception
126
+ * Made configurable connection pool timeout and size
127
+ * Socket connection pooling
128
+ * Updated README
129
+
130
+ *0.3.0 [Final] (May 3, 2009)*
131
+
132
+ * Prepare for v0.3.0
133
+ * README formatting issues
134
+ * README formatting (again)
135
+ * README formatting
136
+ * Updated Rack
137
+ * Make Rack
138
+ * Added instructions for Rack
139
+ * Expiration support for Rack
140
+ * Ensure to test Rails and Sinatra expiration implementations with both MarshaledRedis and DistrbutedMarshaledRedis
141
+ * Expiration support for Merb
142
+ * Use full qualified class names in specs. Minor spec fix.
143
+ * Ported for foreword compatibility the expiration implementation from ezmobius/redis-rb
144
+ * Little spec cleanup
145
+ * Full support for Rack
146
+ * Extracted some logic into RedisFactory
147
+ * Initial support for Rack
148
+
149
+ *0.2.0 [Final] (April 30, 2009)*
150
+
151
+ * Prepare for v0.2.0
152
+ * Links in README
153
+ * Maybe someday I will use the right formating rules at first attempt
154
+ * Still formatting README
155
+ * Formatting for README
156
+ * Updated instructions for Rack
157
+ * Don't require any cache store if no Ruby framework is detected
158
+ * Implemented EntityStore for Rack
159
+ * Added REDIS constant for Rack
160
+ * MetaStore implementation for Rack
161
+
162
+ *0.1.0 [Final] (April 30, 2009)*
163
+
164
+ * Prepare for v0.1.0
165
+ * Sinatra cache support
166
+
167
+ *0.0.3 [Final] (April 30, 2009)*
168
+
169
+ * Prepare for v0.0.3
170
+ * Updated instructions for Merb
171
+ * Hack for Merb cyclic dependency
172
+ * Renaming main lib
173
+ * Merb store #writable always returns true. Added pending test.
174
+ * Merb store #fetch refactoring
175
+ * Updated Redis installation instructions
176
+ * Implemented #fetch for Merb store
177
+ * Implemented #exists?, #delete and #delete_all for Merb cache store
178
+ * Renamed project name in Rakefile
179
+ * Updated project name in README
180
+ * Updated README with Merb instructions
181
+ * Changed name in gemspec
182
+ * New gemspec
183
+ * Initial cache store support for Merb
184
+ * Moving files around
185
+ * Don't complain about missing db in tmp/
186
+
187
+ *0.0.2 [Final] (April 16, 2009)*
188
+
189
+ * Prepare for v0.0.2
190
+ * Updated file list in gemspec
191
+ * Updated README instructions
192
+ * Re-enabled spec for RedisStore#fetch
193
+ * Update rdoc
194
+ * Fix RedisStore#clear when use a cluster
195
+ * Test RedisStore both with single server and with a cluster
196
+ * Fix port in DistributedMarshaledRedis spec
197
+ * Don't slave Redis cluster node
198
+ * Changed Redis cluster configuration
199
+ * Added configuration for Redis cluster
200
+ * Use a distributed system if the store uses more than one server
201
+ * Accept params for client connection
202
+
203
+ *0.0.1 [Final] (April 11, 2009)*
204
+
205
+ * Added :unless_exist option to #write
206
+ * Added failing specs for :expires_in option
207
+ * Made optional args compatible with the Cache interface
208
+ * Implemented #delete_matched, #clear, #stats
209
+ * Implemented #delete, #exist?, #increment, #decrement
210
+ * Introduced RedisStore
211
+ * Initial import
data/Gemfile CHANGED
@@ -7,6 +7,7 @@ group :development do
7
7
  end
8
8
 
9
9
  group :development, :test, :rails3 do
10
+ gem "rack"
10
11
  gem "ruby-debug"
11
12
  gem "rspec"
12
13
  gem "rack-cache"
@@ -16,14 +17,12 @@ end
16
17
 
17
18
  if ENV["REDIS_STORE_ENV"] == "rails3"
18
19
  group :rails3 do
19
- gem "rack", "1.1.0"
20
20
  gem "activesupport", "3.0.0.beta4"
21
21
  gem "actionpack", "3.0.0.beta4"
22
22
  end
23
23
  else
24
24
  group :test do
25
- gem "rack", "1.0.0"
26
- gem "activesupport", "2.3.5"
27
- gem "actionpack", "2.3.5"
25
+ gem "activesupport", "2.3.8"
26
+ gem "actionpack", "2.3.8"
28
27
  end
29
28
  end
data/README.md CHANGED
@@ -28,14 +28,14 @@ Provides a cache store for your Ruby web framework of choice.
28
28
  # Gemfile
29
29
  gem 'rails', '3.0.0.beta4'
30
30
  gem 'redis'
31
- gem 'redis-store', '1.0.0.beta1'
31
+ gem 'redis-store', '1.0.0.beta2'
32
32
 
33
33
  # config/environments/production.rb
34
34
  config.cache_store = :redis_store
35
35
 
36
36
  ### Merb
37
37
 
38
- dependency "redis-store", "1.0.0.beta1"
38
+ dependency "redis-store", "1.0.0.beta2"
39
39
  dependency("merb-cache", merb_gems_version) do
40
40
  Merb::Cache.setup do
41
41
  register(:redis, Merb::Cache::RedisStore, :servers => ["127.0.0.1:6379"])
@@ -75,14 +75,14 @@ Provides a Redis store for Rack::Session. See [http://rack.rubyforge.org/doc/Rac
75
75
  # Gemfile
76
76
  gem 'rails', '3.0.0.beta4'
77
77
  gem 'redis'
78
- gem 'redis-store', '1.0.0.beta1'
78
+ gem 'redis-store', '1.0.0.beta2'
79
79
 
80
80
  # config/initializers/session_store.rb
81
81
  Rails.application.config.session_store :redis_session_store
82
82
 
83
83
  ### Merb
84
84
 
85
- dependency "redis-store", "1.0.0.beta1"
85
+ dependency "redis-store", "1.0.0.beta2"
86
86
  Merb::Config.use do |c|
87
87
  c[:session_store] = "redis"
88
88
  end
data/Rakefile CHANGED
@@ -47,32 +47,10 @@ Spec::Rake::SpecTask.new(:rcov_run) do |t|
47
47
  t.rcov = true
48
48
  end
49
49
 
50
- namespace :redis_cluster do
51
- desc "Starts the redis_cluster"
52
- task :start do
53
- result = RedisClusterRunner.start_detached
54
- raise("Could not start redis-server, aborting.") unless result
55
- end
56
-
57
- desc "Stops the redis_cluster"
58
- task :stop do
59
- RedisClusterRunner.stop
60
- end
61
- end
62
-
63
50
  namespace :bundle do
64
51
  task :clean do
65
52
  system "rm -rf ~/.bundle/ ~/.gem/ .bundle/ Gemfile.lock"
66
53
  end
67
54
  end
68
55
 
69
- # courtesy of http://github.com/ezmobius/redis-rb team
70
56
  load "tasks/redis.tasks.rb"
71
- def invoke_with_redis_cluster(task_name)
72
- begin
73
- Rake::Task["redis_cluster:start"].invoke
74
- Rake::Task[task_name].invoke
75
- ensure
76
- Rake::Task["redis_cluster:stop"].invoke
77
- end
78
- end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0.beta1
1
+ 1.0.0.beta2
@@ -1,4 +1,4 @@
1
- module RedisStore
1
+ module ::RedisStore
2
2
  module Cache
3
3
  module Rails2
4
4
  def write(key, value, options = nil)
@@ -16,6 +16,17 @@ module RedisStore
16
16
  super
17
17
  @data.del key
18
18
  end
19
+
20
+ def exist?(key, options = nil)
21
+ super
22
+ @data.exists key
23
+ end
24
+
25
+ private
26
+ def instrument(operation, key, options = nil)
27
+ log(operation.to_s, key, options)
28
+ yield
29
+ end
19
30
  end
20
31
 
21
32
  module Rails3
@@ -38,7 +49,7 @@ module RedisStore
38
49
  end
39
50
 
40
51
  module Store
41
- include RedisStore.rails3? ? Rails3 : Rails2
52
+ include ::RedisStore.rails3? ? Rails3 : Rails2
42
53
  end
43
54
  end
44
55
  end
@@ -60,9 +71,24 @@ module ActiveSupport
60
71
  @data = Redis::Factory.create(addresses)
61
72
  end
62
73
 
63
- def exist?(key, options = nil)
64
- super
65
- @data.exists key
74
+ # Delete objects for matched keys.
75
+ #
76
+ # Example:
77
+ # cache.del_matched "rab*"
78
+ def delete_matched(matcher, options = nil)
79
+ instrument(:delete_matched, matcher, options) do
80
+ @data.keys(matcher).each { |key| @data.del key }
81
+ end
82
+ end
83
+
84
+ # Reads multiple keys from the cache using a single call to the
85
+ # servers for all keys. Options can be passed in the last argument.
86
+ #
87
+ # Example:
88
+ # cache.read_multi "rabbit", "white-rabbit"
89
+ # cache.read_multi "rabbit", "white-rabbit", :raw => true
90
+ def read_multi(*names)
91
+ @data.marshalled_mget *names
66
92
  end
67
93
 
68
94
  # Increment a key in the store.
@@ -87,8 +113,9 @@ module ActiveSupport
87
113
  # cache.increment "rabbit"
88
114
  # cache.read "rabbit", :raw => true # => "1"
89
115
  def increment(key, amount = 1)
90
- log "increment", key, amount
91
- @data.incrby key, amount
116
+ instrument(:increment, key, :amount => amount) do
117
+ @data.incrby key, amount
118
+ end
92
119
  end
93
120
 
94
121
  # Decrement a key in the store
@@ -113,23 +140,16 @@ module ActiveSupport
113
140
  # cache.decrement "rabbit"
114
141
  # cache.read "rabbit", :raw => true # => "-1"
115
142
  def decrement(key, amount = 1)
116
- log "decrement", key, amount
117
- @data.decrby key, amount
118
- end
119
-
120
- # Delete objects for matched keys.
121
- #
122
- # Example:
123
- # cache.del_matched "rab*"
124
- def delete_matched(matcher, options = nil)
125
- log "delete_matched", matcher, options
126
- @data.keys(matcher).each { |key| @data.del key }
143
+ instrument(:decrement, key, :amount => amount) do
144
+ @data.decrby key, amount
145
+ end
127
146
  end
128
147
 
129
148
  # Clear all the data from the store.
130
149
  def clear
131
- log "clear", nil, nil
132
- @data.flushdb
150
+ instrument(:clear, nil, nil) do
151
+ @data.flushdb
152
+ end
133
153
  end
134
154
 
135
155
  def stats
@@ -59,12 +59,12 @@ module RedisStore
59
59
  end
60
60
  end
61
61
 
62
- unless defined?(ActionDispatch) # rails 2.3.x
63
- class ActionController::Session::RedisSessionStore < ActionController::Session::AbstractStore
62
+ if ::RedisStore.rails3?
63
+ class ActionDispatch::Session::RedisSessionStore < ActionDispatch::Session::AbstractStore
64
64
  include RedisStore::Rack::Session::Rails
65
65
  end
66
- else # rails 3.x
67
- class ActionDispatch::Session::RedisSessionStore < ActionDispatch::Session::AbstractStore
66
+ else
67
+ class ActionController::Session::RedisSessionStore < ActionController::Session::AbstractStore
68
68
  include RedisStore::Rack::Session::Rails
69
69
  end
70
70
  end
@@ -5,7 +5,7 @@ require "redis/marshaled_client"
5
5
  require "redis/distributed_marshaled"
6
6
  require "redis_store/version"
7
7
 
8
- module RedisStore
8
+ module ::RedisStore
9
9
  def self.rails3? #:nodoc:
10
10
  defined?(::Rails) && ::Rails.version =~ /3\.0\.0/
11
11
  end
@@ -31,6 +31,13 @@ class Redis
31
31
  result
32
32
  end
33
33
 
34
+ def marshalled_mget(*keys)
35
+ options = keys.flatten.pop if keys.flatten.last.is_a?(Hash)
36
+ mget(*keys).map do |result|
37
+ unmarshal?(result, options) ? Marshal.load(result) : result
38
+ end
39
+ end
40
+
34
41
  def to_s
35
42
  "Redis Client connected to #{@client.host}:#{@client.port} against DB #{@client.db}"
36
43
  end
@@ -1,9 +1,9 @@
1
- module RedisStore
1
+ module ::RedisStore
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
4
  MINOR = 0
5
5
  TINY = 0
6
- BUILD = "beta1"
6
+ BUILD = "beta2"
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, BUILD].join('.')
9
9
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{redis-store}
8
- s.version = "1.0.0.beta1"
8
+ s.version = "1.0.0.beta2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Luca Guidi"]
12
- s.date = %q{2010-06-09}
12
+ s.date = %q{2010-06-12}
13
13
  s.description = %q{Rack::Session, Rack::Cache and cache Redis stores for Ruby web frameworks.}
14
14
  s.email = %q{guidi.luca@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -17,6 +17,7 @@ Gem::Specification.new do |s|
17
17
  ]
18
18
  s.files = [
19
19
  ".gitignore",
20
+ "CHANGELOG",
20
21
  "Gemfile",
21
22
  "MIT-LICENSE",
22
23
  "README.md",
@@ -37,7 +38,6 @@ Gem::Specification.new do |s|
37
38
  "lib/redis_store/version.rb",
38
39
  "redis-store.gemspec",
39
40
  "spec/cache/merb/redis_store_spec.rb",
40
- "spec/cache/rails/redis_session_store_spec.rb",
41
41
  "spec/cache/rails/redis_store_spec.rb",
42
42
  "spec/cache/sinatra/redis_store_spec.rb",
43
43
  "spec/config/master.conf",
@@ -46,6 +46,7 @@ Gem::Specification.new do |s|
46
46
  "spec/rack/cache/entitystore/pony.jpg",
47
47
  "spec/rack/cache/entitystore/redis_spec.rb",
48
48
  "spec/rack/cache/metastore/redis_spec.rb",
49
+ "spec/rack/session/redis_session_store_spec.rb",
49
50
  "spec/rack/session/redis_spec.rb",
50
51
  "spec/redis/distributed_marshaled_redis_spec.rb",
51
52
  "spec/redis/factory_spec.rb",
@@ -61,11 +62,11 @@ Gem::Specification.new do |s|
61
62
  s.summary = %q{Rack::Session, Rack::Cache and cache Redis stores for Ruby web frameworks.}
62
63
  s.test_files = [
63
64
  "spec/cache/merb/redis_store_spec.rb",
64
- "spec/cache/rails/redis_session_store_spec.rb",
65
65
  "spec/cache/rails/redis_store_spec.rb",
66
66
  "spec/cache/sinatra/redis_store_spec.rb",
67
67
  "spec/rack/cache/entitystore/redis_spec.rb",
68
68
  "spec/rack/cache/metastore/redis_spec.rb",
69
+ "spec/rack/session/redis_session_store_spec.rb",
69
70
  "spec/rack/session/redis_spec.rb",
70
71
  "spec/redis/distributed_marshaled_redis_spec.rb",
71
72
  "spec/redis/factory_spec.rb",
@@ -78,7 +78,7 @@ module ActiveSupport
78
78
  with_store_management do |store|
79
79
  result = store.read("rabbit", :raw => true)
80
80
  result.should include("ActiveSupport::Cache::Entry")
81
- result.should include("\017OpenStruct{\006:\tname\"\nbunny:")
81
+ result.should include("\017OpenStruct{\006:\tname\"\nbunny")
82
82
  end
83
83
  end
84
84
  end
@@ -182,6 +182,124 @@ module ActiveSupport
182
182
  end
183
183
  end
184
184
 
185
+ if ::RedisStore.rails3?
186
+ it "should read multiple keys" do
187
+ @store.write "irish whisky", "Jameson"
188
+ rabbit, whisky = @store.read_multi "rabbit", "irish whisky"
189
+ rabbit.raw_value.should === @rabbit
190
+ whisky.raw_value.should == "Jameson"
191
+ end
192
+ else
193
+ it "should read multiple keys" do
194
+ @store.write "irish whisky", "Jameson"
195
+ rabbit, whisky = @store.read_multi "rabbit", "irish whisky"
196
+ rabbit.should === @rabbit
197
+ whisky.should == "Jameson"
198
+ end
199
+ end
200
+
201
+ if ::RedisStore.rails3?
202
+ describe "notifications" do
203
+ it "should notify on #fetch" do
204
+ with_notifications do
205
+ @store.fetch("radiohead") { "House Of Cards" }
206
+ end
207
+
208
+ read, generate, write = @events
209
+ read.name.should == "cache_read.active_support"
210
+ read.payload.should == { :key => "radiohead" }
211
+ generate.name.should == "cache_generate.active_support"
212
+ generate.payload.should == { :key => "radiohead" }
213
+ write.name.should == "cache_write.active_support"
214
+ write.payload.should == { :key => "radiohead" }
215
+ end
216
+
217
+ it "should notify on #read" do
218
+ with_notifications do
219
+ @store.read "metallica"
220
+ end
221
+
222
+ read = @events.first
223
+ read.name.should == "cache_read.active_support"
224
+ read.payload.should == { :key => "metallica" }
225
+ end
226
+
227
+ # it "should notify on #read_multi" # Not supported in Rails 3
228
+
229
+ it "should notify on #write" do
230
+ with_notifications do
231
+ @store.write "depeche mode", "Enjoy The Silence"
232
+ end
233
+
234
+ write = @events.first
235
+ write.name.should == "cache_write.active_support"
236
+ write.payload.should == { :key => "depeche mode" }
237
+ end
238
+
239
+ it "should notify on #delete" do
240
+ with_notifications do
241
+ @store.delete "the new cardigans"
242
+ end
243
+
244
+ delete = @events.first
245
+ delete.name.should == "cache_delete.active_support"
246
+ delete.payload.should == { :key => "the new cardigans" }
247
+ end
248
+
249
+ it "should notify on #exist?" do
250
+ with_notifications do
251
+ @store.exist? "the smiths"
252
+ end
253
+
254
+ exist = @events.first
255
+ exist.name.should == "cache_exist?.active_support"
256
+ exist.payload.should == { :key => "the smiths" }
257
+ end
258
+
259
+ it "should notify on #delete_matched" do
260
+ with_notifications do
261
+ @store.delete_matched "afterhours*"
262
+ end
263
+
264
+ delete_matched = @events.first
265
+ delete_matched.name.should == "cache_delete_matched.active_support"
266
+ delete_matched.payload.should == { :key => "afterhours*" }
267
+ end
268
+
269
+ it "should notify on #increment" do
270
+ with_notifications do
271
+ @store.increment "pearl jam"
272
+ end
273
+
274
+ increment = @events.first
275
+ increment.name.should == "cache_increment.active_support"
276
+ increment.payload.should == { :key => "pearl jam", :amount => 1 }
277
+ end
278
+
279
+ it "should notify on #decrement" do
280
+ with_notifications do
281
+ @store.decrement "placebo"
282
+ end
283
+
284
+ decrement = @events.first
285
+ decrement.name.should == "cache_decrement.active_support"
286
+ decrement.payload.should == { :key => "placebo", :amount => 1 }
287
+ end
288
+
289
+ # it "should notify on cleanup" # TODO implement in ActiveSupport::Cache::RedisStore
290
+
291
+ it "should notify on clear" do
292
+ with_notifications do
293
+ @store.clear
294
+ end
295
+
296
+ clear = @events.first
297
+ clear.name.should == "cache_clear.active_support"
298
+ clear.payload.should == { :key => nil }
299
+ end
300
+ end
301
+ end
302
+
185
303
  private
186
304
  def instantiate_store(addresses = nil)
187
305
  ActiveSupport::Cache::RedisStore.new(addresses).instance_variable_get(:@data)
@@ -191,6 +309,16 @@ module ActiveSupport
191
309
  yield @store
192
310
  yield @dstore
193
311
  end
312
+
313
+ def with_notifications
314
+ @events = [ ]
315
+ ActiveSupport::Cache::RedisStore.instrument = true
316
+ ActiveSupport::Notifications.subscribe(/^cache_(.*)\.active_support$/) do |*args|
317
+ @events << ActiveSupport::Notifications::Event.new(*args)
318
+ end
319
+ yield
320
+ ActiveSupport::Cache::RedisStore.instrument = false
321
+ end
194
322
  end
195
323
  end
196
324
  end
@@ -1,5 +1,5 @@
1
1
  require File.join(File.dirname(__FILE__), "/../../spec_helper")
2
- RAILS_SESSION_STORE_CLASS = RedisStore.rails3? ? ActionDispatch::Session::RedisSessionStore : ActionController::Session::RedisSessionStore
2
+ RAILS_SESSION_STORE_CLASS = ::RedisStore.rails3? ? ActionDispatch::Session::RedisSessionStore : ActionController::Session::RedisSessionStore
3
3
 
4
4
  describe RAILS_SESSION_STORE_CLASS do
5
5
  attr_reader :app
@@ -56,5 +56,28 @@ describe "Redis::MarshaledClient" do
56
56
  @store.marshalled_setnx "rabbit2", @white_rabbit, :raw => true
57
57
  @store.marshalled_get("rabbit2", :raw => true).should == %(#<OpenStruct color="white">)
58
58
  end
59
+
60
+ it "should unmarshal object(s) on multi get" do
61
+ @store.marshalled_set "rabbit2", @white_rabbit
62
+ rabbit, rabbit2 = @store.marshalled_mget "rabbit", "rabbit2"
63
+ rabbit.should == @rabbit
64
+ rabbit2.should == @white_rabbit
65
+ end
66
+
67
+ if RUBY_VERSION.match /1\.9/
68
+ it "should not unmarshal object(s) on multi get if raw option is true" do
69
+ @store.marshalled_set "rabbit2", @white_rabbit
70
+ rabbit, rabbit2 = @store.marshalled_mget "rabbit", "rabbit2", :raw => true
71
+ rabbit.should == "\x04\bU:\x0FOpenStruct{\x06:\tnameI\"\nbunny\x06:\rencoding\"\rUS-ASCII"
72
+ rabbit2.should == "\x04\bU:\x0FOpenStruct{\x06:\ncolorI\"\nwhite\x06:\rencoding\"\rUS-ASCII"
73
+ end
74
+ else
75
+ it "should not unmarshal object(s) on multi get if raw option is true" do
76
+ @store.marshalled_set "rabbit2", @white_rabbit
77
+ rabbit, rabbit2 = @store.marshalled_mget "rabbit", "rabbit2", :raw => true
78
+ rabbit.should == "\004\bU:\017OpenStruct{\006:\tname\"\nbunny"
79
+ rabbit2.should == "\004\bU:\017OpenStruct{\006:\ncolor\"\nwhite"
80
+ end
81
+ end
59
82
  end
60
83
 
@@ -2,6 +2,6 @@ require File.join(File.dirname(__FILE__), "/../spec_helper")
2
2
 
3
3
  describe RedisStore::VERSION do
4
4
  it "should describe RedisStore version" do
5
- RedisStore::VERSION::STRING.should == "1.0.0.beta1"
5
+ RedisStore::VERSION::STRING.should == "1.0.0.beta2"
6
6
  end
7
7
  end
@@ -159,6 +159,19 @@ namespace :redis do
159
159
  system "bundle exec irb -I lib -I extra -r redis-store.rb"
160
160
  RedisRunner.stop
161
161
  end
162
+
163
+ namespace :cluster do
164
+ desc "Starts the redis_cluster"
165
+ task :start do
166
+ result = RedisClusterRunner.start_detached
167
+ raise("Could not start redis-server, aborting.") unless result
168
+ end
169
+
170
+ desc "Stops the redis_cluster"
171
+ task :stop do
172
+ RedisClusterRunner.stop
173
+ end
174
+ end
162
175
  end
163
176
 
164
177
  namespace :dtach do
@@ -189,3 +202,12 @@ namespace :dtach do
189
202
  puts 'Dtach successfully installed to /usr/bin.'
190
203
  end
191
204
  end
205
+
206
+ def invoke_with_redis_cluster(task_name)
207
+ begin
208
+ Rake::Task["redis:cluster:start"].invoke
209
+ Rake::Task[task_name].invoke
210
+ ensure
211
+ Rake::Task["redis:cluster:stop"].invoke
212
+ end
213
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-store
3
3
  version: !ruby/object:Gem::Version
4
- hash: -1848230051
4
+ hash: -1848230054
5
5
  prerelease: true
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
9
  - 0
10
- - beta1
11
- version: 1.0.0.beta1
10
+ - beta2
11
+ version: 1.0.0.beta2
12
12
  platform: ruby
13
13
  authors:
14
14
  - Luca Guidi
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-06-09 00:00:00 +02:00
19
+ date: 2010-06-12 00:00:00 +02:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -45,6 +45,7 @@ extra_rdoc_files:
45
45
  - README.md
46
46
  files:
47
47
  - .gitignore
48
+ - CHANGELOG
48
49
  - Gemfile
49
50
  - MIT-LICENSE
50
51
  - README.md
@@ -65,7 +66,6 @@ files:
65
66
  - lib/redis_store/version.rb
66
67
  - redis-store.gemspec
67
68
  - spec/cache/merb/redis_store_spec.rb
68
- - spec/cache/rails/redis_session_store_spec.rb
69
69
  - spec/cache/rails/redis_store_spec.rb
70
70
  - spec/cache/sinatra/redis_store_spec.rb
71
71
  - spec/config/master.conf
@@ -74,6 +74,7 @@ files:
74
74
  - spec/rack/cache/entitystore/pony.jpg
75
75
  - spec/rack/cache/entitystore/redis_spec.rb
76
76
  - spec/rack/cache/metastore/redis_spec.rb
77
+ - spec/rack/session/redis_session_store_spec.rb
77
78
  - spec/rack/session/redis_spec.rb
78
79
  - spec/redis/distributed_marshaled_redis_spec.rb
79
80
  - spec/redis/factory_spec.rb
@@ -119,11 +120,11 @@ specification_version: 3
119
120
  summary: Rack::Session, Rack::Cache and cache Redis stores for Ruby web frameworks.
120
121
  test_files:
121
122
  - spec/cache/merb/redis_store_spec.rb
122
- - spec/cache/rails/redis_session_store_spec.rb
123
123
  - spec/cache/rails/redis_store_spec.rb
124
124
  - spec/cache/sinatra/redis_store_spec.rb
125
125
  - spec/rack/cache/entitystore/redis_spec.rb
126
126
  - spec/rack/cache/metastore/redis_spec.rb
127
+ - spec/rack/session/redis_session_store_spec.rb
127
128
  - spec/rack/session/redis_spec.rb
128
129
  - spec/redis/distributed_marshaled_redis_spec.rb
129
130
  - spec/redis/factory_spec.rb