redis-session-store 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -2
- data/.travis.yml +5 -3
- data/AUTHORS.md +1 -0
- data/CHANGELOG.md +12 -1
- data/README.md +7 -6
- data/lib/redis-session-store.rb +9 -4
- data/spec/redis_session_store_spec.rb +23 -0
- metadata +2 -3
- data/.rubocop_todo.yml +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea830a6f15b8fd1ccb1310ab77e2abc54f3b6e70dcef137d81da0929e2e74319
|
4
|
+
data.tar.gz: '013008f119003c119e66226c929da60cd824aab20560cbca017233e1f4e2847e'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69360bd3de339d129ed3fd2863c1880e7030cac9a3edf6ebf6834c8b0c330d0f3062bc70fa53237d7b1318f9c5f309a6dc333da0d943d98fc6762ea996db7a32
|
7
|
+
data.tar.gz: e9bf6c72b4e9175d248bb9306ae6728107ec9675642c3309cb14dcd436e7faaa634ce711da37507932abe115655e4acd1b5d1d78cdeeea5e42cdcea1462f68f9
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
@@ -2,11 +2,13 @@ language: ruby
|
|
2
2
|
sudo: false
|
3
3
|
cache: bundler
|
4
4
|
rvm:
|
5
|
-
- 2.3.
|
6
|
-
-
|
5
|
+
- 2.3.7
|
6
|
+
- 2.4.4
|
7
|
+
- 2.5.1
|
8
|
+
- jruby-9.2.0.0
|
7
9
|
matrix:
|
8
10
|
allow_failures:
|
9
|
-
- rvm: jruby-9.
|
11
|
+
- rvm: jruby-9.2.0.0
|
10
12
|
notifications:
|
11
13
|
email: false
|
12
14
|
deploy:
|
data/AUTHORS.md
CHANGED
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,14 @@
|
|
4
4
|
|
5
5
|
## [Unreleased]
|
6
6
|
|
7
|
+
## [0.11.0] - 2018-08-13
|
8
|
+
### Changed
|
9
|
+
- JRuby to jruby-9.2.0.0
|
10
|
+
- Travis Ruby support: 2.3.7, 2.4.4, 2.5.1
|
11
|
+
|
12
|
+
### Added
|
13
|
+
- :ttl configuration option
|
14
|
+
|
7
15
|
## [0.10.0] - 2018-04-14
|
8
16
|
### Changed
|
9
17
|
- JRuby to jruby-9.1.15.0
|
@@ -216,7 +224,10 @@
|
|
216
224
|
### Added
|
217
225
|
- first working version
|
218
226
|
|
219
|
-
[Unreleased]: https://github.com/roidrage/redis-session-store/compare/v0.
|
227
|
+
[Unreleased]: https://github.com/roidrage/redis-session-store/compare/v0.11.0...HEAD
|
228
|
+
[0.11.0]: https://github.com/roidrage/redis-session-store/compare/v0.10.0...v0.11.0
|
229
|
+
[0.10.0]: https://github.com/roidrage/redis-session-store/compare/v0.9.2...v0.10.0
|
230
|
+
[0.9.2]: https://github.com/roidrage/redis-session-store/compare/v0.9.1...v0.9.2
|
220
231
|
[0.9.1]: https://github.com/roidrage/redis-session-store/compare/v0.9.0...v0.9.1
|
221
232
|
[0.9.0]: https://github.com/roidrage/redis-session-store/compare/v0.8.1...v0.9.0
|
222
233
|
[0.8.1]: https://github.com/roidrage/redis-session-store/compare/v0.8.0...v0.8.1
|
data/README.md
CHANGED
@@ -33,12 +33,13 @@ See `lib/redis-session-store.rb` for a list of valid options.
|
|
33
33
|
In your Rails app, throw in an initializer with the following contents:
|
34
34
|
|
35
35
|
``` ruby
|
36
|
-
|
36
|
+
Rails.application.config.session_store :redis_session_store, {
|
37
37
|
key: 'your_session_key',
|
38
38
|
redis: {
|
39
|
-
expire_after: 120.minutes,
|
39
|
+
expire_after: 120.minutes, # cookie expiration
|
40
|
+
ttl: 120.minutes, # Redis expiration, defaults to 'expire_after'
|
40
41
|
key_prefix: 'myapp:session:',
|
41
|
-
url: 'redis://
|
42
|
+
url: 'redis://localhost:6379/0',
|
42
43
|
}
|
43
44
|
}
|
44
45
|
```
|
@@ -49,7 +50,7 @@ If you want to handle cases where Redis is unavailable, a custom
|
|
49
50
|
callable handler may be provided as `on_redis_down`:
|
50
51
|
|
51
52
|
``` ruby
|
52
|
-
|
53
|
+
Rails.application.config.session_store :redis_session_store, {
|
53
54
|
# ... other options ...
|
54
55
|
on_redis_down: ->(e, env, sid) { do_something_will_ya!(e) }
|
55
56
|
redis: {
|
@@ -69,7 +70,7 @@ custom serializer:
|
|
69
70
|
* `CustomClass` - You can just pass the constant name of any class that responds to `.load` and `.dump`
|
70
71
|
|
71
72
|
``` ruby
|
72
|
-
|
73
|
+
Rails.application.config.session_store :redis_session_store, {
|
73
74
|
# ... other options ...
|
74
75
|
serializer: :hybrid
|
75
76
|
redis: {
|
@@ -88,7 +89,7 @@ custom callable handler may be provided as `on_session_load_error` which
|
|
88
89
|
will be given the error and the session ID.
|
89
90
|
|
90
91
|
``` ruby
|
91
|
-
|
92
|
+
Rails.application.config.session_store :redis_session_store, {
|
92
93
|
# ... other options ...
|
93
94
|
on_session_load_error: ->(e, sid) { do_something_will_ya!(e) }
|
94
95
|
redis: {
|
data/lib/redis-session-store.rb
CHANGED
@@ -3,7 +3,7 @@ require 'redis'
|
|
3
3
|
# Redis session storage for Rails, and for Rails only. Derived from
|
4
4
|
# the MemCacheStore code, simply dropping in Redis instead.
|
5
5
|
class RedisSessionStore < ActionDispatch::Session::AbstractStore
|
6
|
-
VERSION = '0.
|
6
|
+
VERSION = '0.11.0'.freeze
|
7
7
|
# Rails 3.1 and beyond defines the constant elsewhere
|
8
8
|
unless defined?(ENV_SESSION_OPTIONS_KEY)
|
9
9
|
ENV_SESSION_OPTIONS_KEY = if Rack.release.split('.').first.to_i > 1
|
@@ -27,12 +27,12 @@ class RedisSessionStore < ActionDispatch::Session::AbstractStore
|
|
27
27
|
#
|
28
28
|
# ==== Examples
|
29
29
|
#
|
30
|
-
#
|
30
|
+
# Rails.application.config.session_store :redis_session_store, {
|
31
31
|
# key: 'your_session_key',
|
32
32
|
# redis: {
|
33
33
|
# expire_after: 120.minutes,
|
34
34
|
# key_prefix: 'myapp:session:',
|
35
|
-
# url: 'redis://
|
35
|
+
# url: 'redis://localhost:6379/0'
|
36
36
|
# },
|
37
37
|
# on_redis_down: ->(*a) { logger.error("Redis down! #{a.inspect}") }
|
38
38
|
# serializer: :hybrid # migrate from Marshal to JSON
|
@@ -116,7 +116,7 @@ class RedisSessionStore < ActionDispatch::Session::AbstractStore
|
|
116
116
|
end
|
117
117
|
|
118
118
|
def set_session(env, sid, session_data, options = nil)
|
119
|
-
expiry = (options
|
119
|
+
expiry = get_expiry(env, options)
|
120
120
|
if expiry
|
121
121
|
redis.setex(prefixed(sid), expiry, encode(session_data))
|
122
122
|
else
|
@@ -129,6 +129,11 @@ class RedisSessionStore < ActionDispatch::Session::AbstractStore
|
|
129
129
|
end
|
130
130
|
alias write_session set_session
|
131
131
|
|
132
|
+
def get_expiry(env, options)
|
133
|
+
session_storage_options = options || env.fetch(ENV_SESSION_OPTIONS_KEY, {})
|
134
|
+
session_storage_options[:ttl] || session_storage_options[:expire_after]
|
135
|
+
end
|
136
|
+
|
132
137
|
def encode(session_data)
|
133
138
|
serializer.dump(session_data)
|
134
139
|
end
|
@@ -59,6 +59,29 @@ describe RedisSessionStore do
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
+
describe 'when configured with both :ttl and :expire_after' do
|
63
|
+
let(:ttl_seconds) { 60 * 120 }
|
64
|
+
let :options do
|
65
|
+
{
|
66
|
+
key: random_string,
|
67
|
+
secret: random_string,
|
68
|
+
redis: {
|
69
|
+
host: 'hosty.local',
|
70
|
+
port: 16_379,
|
71
|
+
db: 2,
|
72
|
+
key_prefix: 'myapp:session:',
|
73
|
+
ttl: ttl_seconds,
|
74
|
+
expire_after: nil
|
75
|
+
}
|
76
|
+
}
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'assigns the :ttl option to @default_options' do
|
80
|
+
expect(default_options[:ttl]).to eq(ttl_seconds)
|
81
|
+
expect(default_options[:expire_after]).to be_nil
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
62
85
|
describe 'when initializing with top-level redis options' do
|
63
86
|
let :options do
|
64
87
|
{
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis-session-store
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mathias Meyer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -134,7 +134,6 @@ files:
|
|
134
134
|
- ".gitignore"
|
135
135
|
- ".rspec"
|
136
136
|
- ".rubocop.yml"
|
137
|
-
- ".rubocop_todo.yml"
|
138
137
|
- ".simplecov"
|
139
138
|
- ".travis.yml"
|
140
139
|
- AUTHORS.md
|
data/.rubocop_todo.yml
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
# This configuration was generated by
|
2
|
-
# `rubocop --auto-gen-config`
|
3
|
-
# on 2016-07-02 09:22:22 -0400 using RuboCop version 0.41.1.
|
4
|
-
# The point is for the user to remove these configuration records
|
5
|
-
# one by one as the offenses are removed from the code base.
|
6
|
-
# Note that changes in the inspected code, or installation of new
|
7
|
-
# versions of RuboCop, may require this file to be generated again.
|
8
|
-
|
9
|
-
# Offense count: 1
|
10
|
-
# Configuration parameters: CountComments.
|
11
|
-
Metrics/ClassLength:
|
12
|
-
Max: 110
|