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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 76e0b638b6e1d8ee2a3ec1f5868560dc7f73666c
4
- data.tar.gz: 312019d4cbccb178cf6dc8b27728f0f05634c4c9
3
+ metadata.gz: a9190ad054eec78d0314a378fb9617f826c05ab0
4
+ data.tar.gz: 330593cae1a58e77bbcbfbbb516c984b5e1bb7cf
5
5
  SHA512:
6
- metadata.gz: 9bcca09f99836cef68669ced5e42bcc91900c5826206b45bf93d7a13e7e1aa60a541a46d1441f1c27b569568d609c84acf04ef671cbad243a61ce8a23ca02c5e
7
- data.tar.gz: 1b91a951d737f4e2c9399bb6a3370c2af4f052abce6dee80809b603a04dc52630aa7bcba0391a77bd4781dcc2223dac6ee186d11cd779a1b205eeda6d956d342
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 'REDIS_URL' in keeping with Heroku and others' practices.
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
 
@@ -32,8 +32,11 @@ module Rack
32
32
  super
33
33
 
34
34
  @mutex = Mutex.new
35
- @marshaller = options.delete(:marshaller) { Marshal }
36
- @storage = StorageWrapper.new(@marshaller, options.delete(:url) { ENV.fetch('REDIS_URL') }, options[:expire_after])
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
- # Generic storage wrapper.
79
- # Currently using Redis via Redic.
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, expires)
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
@@ -2,7 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'rack-redic'
5
- spec.version = '0.2.1'
5
+ spec.version = '0.2.2'
6
6
  spec.authors = ['Evan Lecklider']
7
7
  spec.email = ['evan@lecklider.com']
8
8
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-redic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Lecklider