rack-redic 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/lib/rack/session/redic.rb +12 -9
- data/rack-redic.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d4afdb628407b7b0dac6cf05ac9ea5d33497bae
|
4
|
+
data.tar.gz: 747344ab157680920425f77776de3b7150d2cd9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7435b1f651cc9952aff451613fc32c6698ef856e3e579b6035d1133d538ba749cbd9ca37fe8cc70f99f68420a1d71b9b9e5d0e16fd6b6d056c3620d8ce331e1b
|
7
|
+
data.tar.gz: aae16f6bce3a267b657b4551eb6e3d2b895635319dc9e3b6c21f58f82a778c64b197bd86dd1b51cb5fa29d4e2e5c9a46e560676018f08ac12009a7d072cc0f59
|
data/Rakefile
CHANGED
data/lib/rack/session/redic.rb
CHANGED
@@ -18,8 +18,8 @@ module Rack
|
|
18
18
|
# required is that this class respond to the `load` and `dump` methods,
|
19
19
|
# returning the session hash and a string respectively.
|
20
20
|
# - :url - Addtionally, you may pass in the URL for your Redis server. The
|
21
|
-
# default URL is fetched from the ENV as 'REDIS_URL' in keeping with
|
22
|
-
# and others' practices.
|
21
|
+
# default URL is fetched from the ENV as 'REDIS_URL' in keeping with
|
22
|
+
# Heroku and others' practices.
|
23
23
|
# - :expire_after - Finally, expiration will be passed to the Redis server
|
24
24
|
# via the 'EX' option on 'SET'. Expiration should be in seconds, just like
|
25
25
|
# Rack's default handling of the :expire_after option. This option will
|
@@ -52,10 +52,8 @@ module Rack
|
|
52
52
|
# Find the session (or generate a blank one).
|
53
53
|
def find_session(_req, sid)
|
54
54
|
@mutex.synchronize do
|
55
|
-
|
56
|
-
|
57
|
-
@storage.set(sid, session)
|
58
|
-
end
|
55
|
+
sid ||= generate_sid
|
56
|
+
session = @storage.get(sid) || @storage.init(sid, {})
|
59
57
|
|
60
58
|
[sid, session]
|
61
59
|
end
|
@@ -78,8 +76,7 @@ module Rack
|
|
78
76
|
end
|
79
77
|
end
|
80
78
|
|
81
|
-
|
82
|
-
|
79
|
+
##
|
83
80
|
# A wrapper around Redic to simplify calls.
|
84
81
|
class Storage
|
85
82
|
# Redis commands.
|
@@ -103,13 +100,18 @@ module Rack
|
|
103
100
|
@storage.call(EXISTS, id) != ZERO
|
104
101
|
end
|
105
102
|
|
103
|
+
def init(sid, initial)
|
104
|
+
set(sid, initial)
|
105
|
+
initial
|
106
|
+
end
|
107
|
+
|
106
108
|
def get(id)
|
107
109
|
deserialize(@storage.call(GET, id))
|
108
110
|
end
|
109
111
|
|
110
112
|
def set(id, object)
|
111
113
|
arguments = [SET, id, serialize(object)]
|
112
|
-
arguments
|
114
|
+
arguments += [EX, @expires] if @expires
|
113
115
|
|
114
116
|
@storage.call(*arguments)
|
115
117
|
end
|
@@ -127,6 +129,7 @@ module Rack
|
|
127
129
|
|
128
130
|
# Should always return the session object.
|
129
131
|
def deserialize(string)
|
132
|
+
return unless string
|
130
133
|
@marshaller.load(Zlib::Inflate.inflate(string.unpack(PACK).first))
|
131
134
|
end
|
132
135
|
end
|
data/rack-redic.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-redic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evan Lecklider
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
73
|
version: '0'
|
74
74
|
requirements: []
|
75
75
|
rubyforge_project:
|
76
|
-
rubygems_version: 2.6.
|
76
|
+
rubygems_version: 2.6.7
|
77
77
|
signing_key:
|
78
78
|
specification_version: 4
|
79
79
|
summary: Rack::Session in Redis via Redic
|