rack-redic 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -6
- data/lib/rack/session/redic.rb +8 -6
- data/rack-redic.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9190ad054eec78d0314a378fb9617f826c05ab0
|
4
|
+
data.tar.gz: 330593cae1a58e77bbcbfbbb516c984b5e1bb7cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34b0c681b2aedc62288d23cd78accec23ff69c69c6c30aa8cbe1f5daeda69f294f5eb76d87c3a878b15dae7e011085a5ac56d64403b4b87351236b7c6143b1cd
|
7
|
+
data.tar.gz: 35f31a99b9a287fc994a8953bde3617401a3313730ee52d5e7db5ff57a0642b011f9bdd99e89b0f0def166b20574d70d55df1f48e52e13ab53f7158ba7e207a1
|
data/README.md
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
# Rack::Redic
|
1
|
+
# Rack::Session::Redic
|
2
2
|
|
3
|
-
Rack::Session::Redic provides simple cookie based session management. Session data is stored in Redis via the [Redic](https://github.com/amakawa/redic) gem. The corresponding session key is maintained in the cookie.
|
3
|
+
`Rack::Session::Redic` provides simple cookie based session management. Session data is stored in [Redis](http://redis.io) via the [Redic](https://github.com/amakawa/redic) gem. The corresponding session key is maintained in the cookie.
|
4
4
|
|
5
5
|
Options include:
|
6
6
|
|
7
7
|
- `:marshaller` - You may optionally supply the class/module you would like to use when marshalling objects in and out of Redis. All that is required is that this class respond to the `load` and `dump` methods, returning the session hash and a string respectively.
|
8
|
-
- `:url` - Addtionally, you may pass in the URL for your Redis server. The default URL is fetched from the ENV as
|
8
|
+
- `:url` - Addtionally, you may pass in the URL for your Redis server. The default URL is fetched from the `ENV` as `REDIS_URL` in keeping with Heroku and others' practices.
|
9
9
|
- `:expire_after` - Finally, expiration will be passed to the Redis server via the 'EX' option on 'SET'. Expiration should be in seconds, just like Rack's default handling of the `:expire_after` option. This option will refresh the expiration set in Redis with each request.
|
10
10
|
|
11
|
-
Any other options will get passed to Rack::Session::Abstract::Persisted
|
11
|
+
Any other options will get passed to `Rack::Session::Abstract::Persisted`.
|
12
12
|
|
13
13
|
|
14
14
|
## Installation
|
@@ -40,10 +40,10 @@ use Rack::Session::Redic
|
|
40
40
|
use Rack::Session::Redic, marshaller: Oj
|
41
41
|
|
42
42
|
# And/or pass in the URL of your Redis server.
|
43
|
-
use Rack::Session::Redic, marshaller: Oj, url: 'redis://host'
|
43
|
+
use Rack::Session::Redic, marshaller: Oj, url: 'redis://host:port'
|
44
44
|
|
45
45
|
# And/or pass in the expiration. (1_800 is 30 minutes in seconds)
|
46
|
-
use Rack::Session::Redic, marshaller: Oj, url: 'redis://host', expire_after: 1_800
|
46
|
+
use Rack::Session::Redic, marshaller: Oj, url: 'redis://host:port', expire_after: 1_800
|
47
47
|
```
|
48
48
|
|
49
49
|
|
data/lib/rack/session/redic.rb
CHANGED
@@ -32,8 +32,11 @@ module Rack
|
|
32
32
|
super
|
33
33
|
|
34
34
|
@mutex = Mutex.new
|
35
|
-
@
|
36
|
-
|
35
|
+
@storage = Storage.new(
|
36
|
+
options[:expire_after],
|
37
|
+
options.delete(:marshaller) { Marshal },
|
38
|
+
options.delete(:url) { ENV.fetch('REDIS_URL') }
|
39
|
+
)
|
37
40
|
end
|
38
41
|
|
39
42
|
# Only accept a generated session ID if it doesn't exist.
|
@@ -75,15 +78,14 @@ module Rack
|
|
75
78
|
|
76
79
|
private
|
77
80
|
|
78
|
-
#
|
79
|
-
|
80
|
-
class StorageWrapper
|
81
|
+
# A wrapper around Redic to simplify calls.
|
82
|
+
class Storage
|
81
83
|
DELETE = 'DEL'
|
82
84
|
EXISTS = 'EXISTS'
|
83
85
|
GET = 'GET'
|
84
86
|
SET = 'SET'
|
85
87
|
|
86
|
-
def initialize(marshaller, url
|
88
|
+
def initialize(expires, marshaller, url)
|
87
89
|
@expires = expires
|
88
90
|
@marshaller = marshaller
|
89
91
|
@storage = ::Redic.new(url)
|
data/rack-redic.gemspec
CHANGED