redis-rack 2.1.0.pre → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -2
- data/lib/rack/session/redis.rb +18 -9
- data/lib/redis/rack/version.rb +1 -2
- data/redis-rack.gemspec +1 -3
- data/test/rack/session/redis_test.rb +8 -6
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd358598a3b5173b0af0e6af5a0eb8544d33beb746a24c0d4ae01cb01e5e82c1
|
4
|
+
data.tar.gz: 9afa606f06fc3a5b6812ac5d5a961bc440df74b2ac27160a03536fa0f69d7474
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a88c2a36dca22320e1e8d015fbfd0ece8b71f814c60e7a90cb1036ae8cee9f713f3321389f286c707b982a5a82c8b5078ffe93b58c37e17367fec6aa8544e209
|
7
|
+
data.tar.gz: 41722398d1973c7390155fb71c9fe17e3e99e1b0093db1b7d588c77dec01487390b4208a8e04ff0a8050d0f03029c606d619e68da7cbfed9e3bdf397159c0502
|
data/.travis.yml
CHANGED
data/lib/rack/session/redis.rb
CHANGED
@@ -5,10 +5,10 @@ require 'redis/rack/connection'
|
|
5
5
|
|
6
6
|
module Rack
|
7
7
|
module Session
|
8
|
-
class Redis < Abstract::
|
8
|
+
class Redis < Abstract::PersistedSecure
|
9
9
|
attr_reader :mutex
|
10
10
|
|
11
|
-
DEFAULT_OPTIONS = Abstract::
|
11
|
+
DEFAULT_OPTIONS = Abstract::ID::DEFAULT_OPTIONS.merge(
|
12
12
|
:redis_server => 'redis://127.0.0.1:6379/0/rack:session'
|
13
13
|
)
|
14
14
|
|
@@ -24,7 +24,7 @@ module Rack
|
|
24
24
|
loop do
|
25
25
|
sid = generate_sid
|
26
26
|
first = with do |c|
|
27
|
-
[*c.setnx(sid, session, @default_options)].first
|
27
|
+
[*c.setnx(sid.private_id, session, @default_options)].first
|
28
28
|
end
|
29
29
|
break sid if [1, true].include?(first)
|
30
30
|
end
|
@@ -35,7 +35,7 @@ module Rack
|
|
35
35
|
[generate_sid, {}]
|
36
36
|
else
|
37
37
|
with_lock(req, [nil, {}]) do
|
38
|
-
unless sid and session =
|
38
|
+
unless sid and session = get_session_with_fallback(sid)
|
39
39
|
session = {}
|
40
40
|
sid = generate_unique_sid(session)
|
41
41
|
end
|
@@ -44,16 +44,19 @@ module Rack
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
def write_session(req,
|
47
|
+
def write_session(req, sid, new_session, options)
|
48
48
|
with_lock(req, false) do
|
49
|
-
with { |c| c.set
|
50
|
-
|
49
|
+
with { |c| c.set sid.private_id, new_session, options }
|
50
|
+
sid
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
def delete_session(req,
|
54
|
+
def delete_session(req, sid, options)
|
55
55
|
with_lock(req) do
|
56
|
-
with
|
56
|
+
with do |c|
|
57
|
+
c.del(sid.public_id)
|
58
|
+
c.del(sid.private_id)
|
59
|
+
end
|
57
60
|
generate_sid unless options[:drop]
|
58
61
|
end
|
59
62
|
end
|
@@ -78,6 +81,12 @@ module Rack
|
|
78
81
|
def with(&block)
|
79
82
|
@conn.with(&block)
|
80
83
|
end
|
84
|
+
|
85
|
+
private
|
86
|
+
|
87
|
+
def get_session_with_fallback(sid)
|
88
|
+
with { |c| c.get(sid.private_id) || c.get(sid.public_id) }
|
89
|
+
end
|
81
90
|
end
|
82
91
|
end
|
83
92
|
end
|
data/lib/redis/rack/version.rb
CHANGED
data/redis-rack.gemspec
CHANGED
@@ -12,15 +12,13 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.description = %q{Redis Store for Rack applications}
|
13
13
|
s.license = 'MIT'
|
14
14
|
|
15
|
-
s.rubyforge_project = 'redis-rack'
|
16
|
-
|
17
15
|
s.files = `git ls-files`.split("\n")
|
18
16
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
17
|
s.executables = []
|
20
18
|
s.require_paths = ["lib"]
|
21
19
|
|
22
20
|
s.add_runtime_dependency 'redis-store', ['< 2', '>= 1.2']
|
23
|
-
s.add_runtime_dependency 'rack', '>=
|
21
|
+
s.add_runtime_dependency 'rack', '>= 2.0.8', '< 3'
|
24
22
|
|
25
23
|
s.add_development_dependency 'rake', '~> 10'
|
26
24
|
s.add_development_dependency 'bundler', '> 1', '< 3'
|
@@ -93,7 +93,7 @@ describe Rack::Session::Redis do
|
|
93
93
|
it "does not store a blank session" do
|
94
94
|
session_store = Rack::Session::Redis.new(incrementor)
|
95
95
|
sid = session_store.generate_unique_sid({})
|
96
|
-
session_store.with { |c| c.get(sid).must_be_nil }
|
96
|
+
session_store.with { |c| c.get(sid.private_id).must_be_nil }
|
97
97
|
end
|
98
98
|
|
99
99
|
it "locks the store mutex" do
|
@@ -299,10 +299,11 @@ describe Rack::Session::Redis do
|
|
299
299
|
|
300
300
|
res0 = req.get("/")
|
301
301
|
session_id = (cookie = res0["Set-Cookie"])[session_match, 1]
|
302
|
-
|
302
|
+
sid = Rack::Session::SessionId.new(session_id)
|
303
|
+
ses0 = pool.with { |c| c.get(sid.private_id) }
|
303
304
|
|
304
305
|
req.get("/", "HTTP_COOKIE" => cookie)
|
305
|
-
ses1 = pool.with { |c| c.get(
|
306
|
+
ses1 = pool.with { |c| c.get(sid.private_id) }
|
306
307
|
|
307
308
|
ses1.wont_equal(ses0)
|
308
309
|
end
|
@@ -322,6 +323,7 @@ describe Rack::Session::Redis do
|
|
322
323
|
res.body.must_equal('{"counter"=>1}')
|
323
324
|
cookie = res["Set-Cookie"]
|
324
325
|
session_id = cookie[session_match, 1]
|
326
|
+
sid = Rack::Session::SessionId.new(session_id)
|
325
327
|
|
326
328
|
delta_incrementor = lambda do |env|
|
327
329
|
# emulate disconjoinment of threading
|
@@ -343,7 +345,7 @@ describe Rack::Session::Redis do
|
|
343
345
|
request.body.must_include('"counter"=>2')
|
344
346
|
end
|
345
347
|
|
346
|
-
session = pool.with { |c| c.get(
|
348
|
+
session = pool.with { |c| c.get(sid.private_id) }
|
347
349
|
session.size.must_equal(tnum+1) # counter
|
348
350
|
session['counter'].must_equal(2) # meeeh
|
349
351
|
|
@@ -360,7 +362,7 @@ describe Rack::Session::Redis do
|
|
360
362
|
request.body.must_include('"counter"=>3')
|
361
363
|
end
|
362
364
|
|
363
|
-
session = pool.with { |c| c.get(
|
365
|
+
session = pool.with { |c| c.get(sid.private_id) }
|
364
366
|
session.size.must_equal(tnum+1)
|
365
367
|
session['counter'].must_equal(3)
|
366
368
|
|
@@ -382,7 +384,7 @@ describe Rack::Session::Redis do
|
|
382
384
|
request.body.must_include('"foo"=>"bar"')
|
383
385
|
end
|
384
386
|
|
385
|
-
session = pool.with { |c| c.get(
|
387
|
+
session = pool.with { |c| c.get(sid.private_id) }
|
386
388
|
session.size.must_equal(r.size+1)
|
387
389
|
session['counter'].must_be_nil
|
388
390
|
session['foo'].must_equal('bar')
|
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.1.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luca Guidi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis-store
|
@@ -36,7 +36,7 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version:
|
39
|
+
version: 2.0.8
|
40
40
|
- - "<"
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: '3'
|
@@ -46,7 +46,7 @@ dependencies:
|
|
46
46
|
requirements:
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version:
|
49
|
+
version: 2.0.8
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '3'
|
@@ -195,9 +195,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
195
195
|
version: '0'
|
196
196
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
197
197
|
requirements:
|
198
|
-
- - "
|
198
|
+
- - ">="
|
199
199
|
- !ruby/object:Gem::Version
|
200
|
-
version:
|
200
|
+
version: '0'
|
201
201
|
requirements: []
|
202
202
|
rubygems_version: 3.0.3
|
203
203
|
signing_key:
|