redis-rack 2.0.2 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.travis.yml +4 -0
- data/Appraisals +7 -0
- data/Rakefile +6 -0
- data/bin/appraisal +17 -0
- data/bin/rake +17 -0
- data/gemfiles/rack_1.gemfile +7 -0
- data/gemfiles/rack_2.gemfile +7 -0
- data/lib/rack/session/redis.rb +7 -4
- data/lib/redis/rack/version.rb +1 -1
- data/redis-rack.gemspec +2 -1
- data/test/rack/session/redis_test.rb +32 -1
- metadata +27 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 241656b9de13ca2a3a51554244fd812c376f47a3
|
4
|
+
data.tar.gz: 1be1cc86120b1cddffd41d55a826154cdd3878ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c269d47a297d858229722d566df37c09eaf0624e799dcbb9e7840fa069a2a9b3de710fb68dbce5886d187f53bc38eb594d0782e6fc3903514743ee696feffad6
|
7
|
+
data.tar.gz: d644ed731fbb18bb1b793743e46d29af225946ea72560e81946f2484f081efb6466a3ec072291ee60e5265380f3ca846c0aa27cf3cfe92ff07d6739c572789d6
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Appraisals
ADDED
data/Rakefile
CHANGED
data/bin/appraisal
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
#
|
4
|
+
# This file was generated by Bundler.
|
5
|
+
#
|
6
|
+
# The application 'appraisal' is installed as part of a gem, and
|
7
|
+
# this file is here to facilitate running it.
|
8
|
+
#
|
9
|
+
|
10
|
+
require "pathname"
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
12
|
+
Pathname.new(__FILE__).realpath)
|
13
|
+
|
14
|
+
require "rubygems"
|
15
|
+
require "bundler/setup"
|
16
|
+
|
17
|
+
load Gem.bin_path("appraisal", "appraisal")
|
data/bin/rake
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
#
|
4
|
+
# This file was generated by Bundler.
|
5
|
+
#
|
6
|
+
# The application 'rake' is installed as part of a gem, and
|
7
|
+
# this file is here to facilitate running it.
|
8
|
+
#
|
9
|
+
|
10
|
+
require "pathname"
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
12
|
+
Pathname.new(__FILE__).realpath)
|
13
|
+
|
14
|
+
require "rubygems"
|
15
|
+
require "bundler/setup"
|
16
|
+
|
17
|
+
load Gem.bin_path("rake", "rake")
|
data/lib/rack/session/redis.rb
CHANGED
@@ -23,9 +23,9 @@ module Rack
|
|
23
23
|
pool_options[:size] = options[:pool_size] if options[:pool_size]
|
24
24
|
pool_options[:timeout] = options[:pool_timeout] if options[:pool_timeout]
|
25
25
|
@pooled = true
|
26
|
-
::ConnectionPool.new(pool_options) { ::Redis::Store::Factory.create(@default_options[:redis_server]) }
|
26
|
+
::ConnectionPool.new(pool_options) { ::Redis::Store::Factory.create(@default_options[:redis_server]) }
|
27
27
|
else
|
28
|
-
@default_options.has_key?(:redis_store) ?
|
28
|
+
@default_options.has_key?(:redis_store) ?
|
29
29
|
@default_options[:redis_store] :
|
30
30
|
::Redis::Store::Factory.create(@default_options[:redis_server])
|
31
31
|
|
@@ -70,8 +70,12 @@ module Rack
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
+
def threadsafe?
|
74
|
+
@default_options.fetch(:threadsafe, true)
|
75
|
+
end
|
76
|
+
|
73
77
|
def with_lock(env, default=nil)
|
74
|
-
@mutex.lock if env['rack.multithread']
|
78
|
+
@mutex.lock if env['rack.multithread'] && threadsafe?
|
75
79
|
yield
|
76
80
|
rescue Errno::ECONNREFUSED
|
77
81
|
if $VERBOSE
|
@@ -94,4 +98,3 @@ module Rack
|
|
94
98
|
end
|
95
99
|
end
|
96
100
|
end
|
97
|
-
|
data/lib/redis/rack/version.rb
CHANGED
data/redis-rack.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
22
|
-
s.add_runtime_dependency 'redis-store', ['<
|
22
|
+
s.add_runtime_dependency 'redis-store', ['< 2', '>= 1.2']
|
23
23
|
s.add_runtime_dependency 'rack', '>= 1.5', '< 3'
|
24
24
|
|
25
25
|
s.add_development_dependency 'rake', '~> 10'
|
@@ -28,5 +28,6 @@ Gem::Specification.new do |s|
|
|
28
28
|
s.add_development_dependency 'minitest', '~> 5'
|
29
29
|
s.add_development_dependency 'redis-store-testing'
|
30
30
|
s.add_development_dependency 'connection_pool', '~> 1.2.0'
|
31
|
+
s.add_development_dependency 'appraisal'
|
31
32
|
end
|
32
33
|
|
@@ -53,7 +53,6 @@ describe Rack::Session::Redis do
|
|
53
53
|
session_store.with { |connection| connection.to_s.must_match(/127\.0\.0\.1:6380 against DB 1$/) }
|
54
54
|
end
|
55
55
|
|
56
|
-
|
57
56
|
it "can use a supplied pool" do
|
58
57
|
session_store = Rack::Session::Redis.new(incrementor, pool: ::ConnectionPool.new(size: 1, timeout: 1) { ::Redis::Store::Factory.create("redis://127.0.0.1:6380/1")})
|
59
58
|
session_store.pool.class.must_equal ::ConnectionPool
|
@@ -82,6 +81,38 @@ describe Rack::Session::Redis do
|
|
82
81
|
pool.pool.to_s.must_match(/127\.0\.0\.1:6380 against DB 1$/)
|
83
82
|
end
|
84
83
|
|
84
|
+
it "is threadsafe by default" do
|
85
|
+
sesion_store = Rack::Session::Redis.new(incrementor)
|
86
|
+
sesion_store.threadsafe?.must_equal(true)
|
87
|
+
end
|
88
|
+
|
89
|
+
it "locks the store mutex" do
|
90
|
+
mutex = Mutex.new
|
91
|
+
mutex.expects(:lock).once
|
92
|
+
sesion_store = Rack::Session::Redis.new(incrementor)
|
93
|
+
sesion_store.instance_variable_set(:@mutex, mutex)
|
94
|
+
was_yielded = false
|
95
|
+
sesion_store.with_lock({'rack.multithread' => true}) { was_yielded = true}
|
96
|
+
was_yielded.must_equal(true)
|
97
|
+
end
|
98
|
+
|
99
|
+
describe "threadsafe disabled" do
|
100
|
+
it "can have the global lock disabled" do
|
101
|
+
sesion_store = Rack::Session::Redis.new(incrementor, :threadsafe => false)
|
102
|
+
sesion_store.threadsafe?.must_equal(false)
|
103
|
+
end
|
104
|
+
|
105
|
+
it "does not lock the store mutex" do
|
106
|
+
mutex = Mutex.new
|
107
|
+
mutex.expects(:lock).never
|
108
|
+
sesion_store = Rack::Session::Redis.new(incrementor, :threadsafe => false)
|
109
|
+
sesion_store.instance_variable_set(:@mutex, mutex)
|
110
|
+
was_yielded = false
|
111
|
+
sesion_store.with_lock({'rack.multithread' => true}) { was_yielded = true}
|
112
|
+
was_yielded.must_equal(true)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
85
116
|
it "creates a new cookie" do
|
86
117
|
with_pool_management(incrementor) do |pool|
|
87
118
|
res = Rack::MockRequest.new(pool).get("/")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis-rack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luca Guidi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis-store
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "<"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2'
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '1.2'
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - "<"
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
29
|
+
version: '2'
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '1.2'
|
@@ -134,20 +134,41 @@ dependencies:
|
|
134
134
|
- - "~>"
|
135
135
|
- !ruby/object:Gem::Version
|
136
136
|
version: 1.2.0
|
137
|
+
- !ruby/object:Gem::Dependency
|
138
|
+
name: appraisal
|
139
|
+
requirement: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - ">="
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
type: :development
|
145
|
+
prerelease: false
|
146
|
+
version_requirements: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - ">="
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '0'
|
137
151
|
description: Redis Store for Rack applications
|
138
152
|
email:
|
139
153
|
- me@lucaguidi.com
|
140
|
-
executables:
|
154
|
+
executables:
|
155
|
+
- appraisal
|
156
|
+
- rake
|
141
157
|
extensions: []
|
142
158
|
extra_rdoc_files: []
|
143
159
|
files:
|
144
160
|
- ".gitignore"
|
145
161
|
- ".ruby-version"
|
146
162
|
- ".travis.yml"
|
163
|
+
- Appraisals
|
147
164
|
- Gemfile
|
148
165
|
- MIT-LICENSE
|
149
166
|
- README.md
|
150
167
|
- Rakefile
|
168
|
+
- bin/appraisal
|
169
|
+
- bin/rake
|
170
|
+
- gemfiles/rack_1.gemfile
|
171
|
+
- gemfiles/rack_2.gemfile
|
151
172
|
- lib/rack/session/redis.rb
|
152
173
|
- lib/redis-rack.rb
|
153
174
|
- lib/redis/rack/version.rb
|
@@ -174,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
195
|
version: '0'
|
175
196
|
requirements: []
|
176
197
|
rubyforge_project: redis-rack
|
177
|
-
rubygems_version: 2.6.
|
198
|
+
rubygems_version: 2.6.12
|
178
199
|
signing_key:
|
179
200
|
specification_version: 4
|
180
201
|
summary: Redis Store for Rack
|