redis-session-store 0.6.1 → 0.6.4

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2b6b105a9579a8c097a1234c80dc058309866fe6
4
+ data.tar.gz: 2c405132ca0f846a51189e8a63d0a02ab3d974b5
5
+ SHA512:
6
+ metadata.gz: af87b6104ce6ae3e347a22cc6da952c6aae4fd6ca758e563ebd03e2c966e6546270e152770b25820897e91a5f53d6ceae9c31049efb0105752af3d46798ed644
7
+ data.tar.gz: 5d4075ed6b6d493659b39d7feddc68b1cb9d8066659cba7147f9e47de3c7b4d749df56a6412d7c0f43936591288b9edf0b7d500259d1b5242380afec3e1919a1
data/.rubocop.yml CHANGED
@@ -12,4 +12,4 @@ FileName:
12
12
  # Offense count: 1
13
13
  # Configuration parameters: CountComments.
14
14
  ClassLength:
15
- Max: 103
15
+ Max: 110
data/CHANGELOG.md CHANGED
@@ -1,6 +1,23 @@
1
1
  redis-session-store history
2
2
  ===========================
3
3
 
4
+ ## v0.6.4 (2014-04-04)
5
+
6
+ * Reverting `setnx` usage in v0.6.3 so we can change our sessions.
7
+
8
+ ## v0.6.3 (2014-04-01)
9
+
10
+ * Reverting the `#setnx` change in `0.6.2` as it behaved badly under
11
+ load, hitting yet another race condition issue and pegging the CPU.
12
+ * Setting session ID with a multi-call `#setnx` and `#expire` instead of
13
+ `#setex`.
14
+
15
+ ## v0.6.2 (2014-03-31)
16
+
17
+ * Use `#setnx` instead of `#get` when checking for session ID
18
+ collisions, which is slightly more paranoid and should help avoid a
19
+ particularly nasty edge case.
20
+
4
21
  ## v0.6.1 (2014-03-17)
5
22
 
6
23
  * Fix compatibility with `ActionDispatch::Request::Session::Options`
data/README.md CHANGED
@@ -3,6 +3,7 @@ Redis Session Store
3
3
 
4
4
  [![Build Status](https://travis-ci.org/roidrage/redis-session-store.png?branch=master)](https://travis-ci.org/roidrage/redis-session-store)
5
5
  [![Code Climate](https://codeclimate.com/github/roidrage/redis-session-store.png)](https://codeclimate.com/github/roidrage/redis-session-store)
6
+ [![Gem Version](https://badge.fury.io/rb/redis-session-store.png)](http://badge.fury.io/rb/redis-session-store)
6
7
 
7
8
  A simple Redis-based session store for Rails. But why, you ask,
8
9
  when there's [redis-store](http://github.com/jodosha/redis-store/)?
@@ -19,21 +20,13 @@ only suitable for Rails applications. For other frameworks or
19
20
  drop-in support for caching, check out
20
21
  [redis-store](http://github.com/jodosha/redis-store/)
21
22
 
22
- Rails 2 Compatibility
23
- ---------------------
24
-
25
- This gem is currently only compatible with Rails 3+. If you need
26
- Rails 2 compatibility, be sure to pin to a lower version like so:
27
-
28
- ``` ruby
29
- gem 'redis-session-store', '< 0.3'
30
- ```
31
-
32
23
  Installation
33
24
  ------------
34
25
 
35
- ``` bash
36
- gem install redis-session-store
26
+ For Rails 3+, adding this to your Gemfile will do the trick.
27
+
28
+ ``` ruby
29
+ gem 'redis-session-store'
37
30
  ```
38
31
 
39
32
  Configuration
@@ -43,7 +36,7 @@ See `lib/redis-session-store.rb` for a list of valid options.
43
36
  In your Rails app, throw in an initializer with the following contents:
44
37
 
45
38
  ``` ruby
46
- My::Application.config.session_store = :redis_session_store, {
39
+ My::Application.config.session_store :redis_session_store, {
47
40
  key: 'your_session_key',
48
41
  redis: {
49
42
  db: 2,
@@ -62,7 +55,7 @@ collides with an existing session ID, a custom callable handler may be
62
55
  provided as `on_sid_collision`:
63
56
 
64
57
  ``` ruby
65
- My::Application.config.session_store = :redis_session_store, {
58
+ My::Application.config.session_store :redis_session_store, {
66
59
  # ... other options ...
67
60
  on_sid_collision: ->(sid) { Rails.logger.warn("SID collision! #{sid}") }
68
61
  }
@@ -74,7 +67,7 @@ If you want to handle cases where Redis is unavailable, a custom
74
67
  callable handler may be provided as `on_redis_down`:
75
68
 
76
69
  ``` ruby
77
- My::Application.config.session_store = :redis_session_store, {
70
+ My::Application.config.session_store :redis_session_store, {
78
71
  # ... other options ...
79
72
  on_redis_down: ->(e, env, sid) { do_something_will_ya!(e) }
80
73
  }
@@ -91,7 +84,7 @@ custom serializer:
91
84
  * `CustomClass` - You can just pass the constant name of any class that responds to `.load` and `.dump`
92
85
 
93
86
  ``` ruby
94
- My::Application.config.session_store = :redis_session_store, {
87
+ My::Application.config.session_store :redis_session_store, {
95
88
  # ... other options ...
96
89
  serializer: :hybrid
97
90
  }
@@ -107,7 +100,7 @@ custom callable handler may be provided as `on_session_load_error` which
107
100
  will be given the error and the session ID.
108
101
 
109
102
  ``` ruby
110
- My::Application.config.session_store = :redis_session_store, {
103
+ My::Application.config.session_store :redis_session_store, {
111
104
  # ... other options ...
112
105
  on_session_load_error: ->(e, sid) { do_something_will_ya!(e) }
113
106
  }
@@ -115,6 +108,15 @@ My::Application.config.session_store = :redis_session_store, {
115
108
 
116
109
  **Note** The session will *always* be destroyed when it cannot be loaded.
117
110
 
111
+ Rails 2 Compatibility
112
+ ---------------------
113
+
114
+ This gem is currently only compatible with Rails 3+. If you need
115
+ Rails 2 compatibility, be sure to pin to a lower version like so:
116
+
117
+ ``` ruby
118
+ gem 'redis-session-store', '< 0.3'
119
+ ```
118
120
  Contributing, Authors, & License
119
121
  --------------------------------
120
122
 
@@ -4,7 +4,7 @@ require 'redis'
4
4
  # Redis session storage for Rails, and for Rails only. Derived from
5
5
  # the MemCacheStore code, simply dropping in Redis instead.
6
6
  class RedisSessionStore < ActionDispatch::Session::AbstractStore
7
- VERSION = '0.6.1'
7
+ VERSION = '0.6.4'
8
8
 
9
9
  # ==== Options
10
10
  # * +:key+ - Same as with the other cookie stores, key name
@@ -21,7 +21,7 @@ class RedisSessionStore < ActionDispatch::Session::AbstractStore
21
21
  #
22
22
  # ==== Examples
23
23
  #
24
- # My::Application.config.session_store = :redis_session_store, {
24
+ # My::Application.config.session_store :redis_session_store, {
25
25
  # key: 'your_session_key',
26
26
  # redis: {
27
27
  # db: 2,
@@ -108,8 +108,8 @@ class RedisSessionStore < ActionDispatch::Session::AbstractStore
108
108
  serializer.load(data)
109
109
  end
110
110
 
111
- def set_session(env, sid, session_data, options = nil)
112
- expiry = (options || env[ENV_SESSION_OPTIONS_KEY])[:expire_after]
111
+ def set_session(env, sid, session_data, options = nil) # rubocop: disable MethodLength, LineLength
112
+ expiry = (options || env.fetch(ENV_SESSION_OPTIONS_KEY))[:expire_after]
113
113
  if expiry
114
114
  redis.setex(prefixed(sid), expiry, encode(session_data))
115
115
  else
@@ -450,4 +450,30 @@ describe RedisSessionStore do
450
450
  end
451
451
  end
452
452
  end
453
+
454
+ describe 'setting the session' do
455
+ it 'allows changing the session' do
456
+ env = { 'rack.session.options' => {} }
457
+ sid = 1234
458
+ store.stub(:redis).and_return(Redis.new)
459
+ data1 = { 'foo' => 'bar' }
460
+ store.send(:set_session, env, sid, data1)
461
+ data2 = { 'baz' => 'wat' }
462
+ store.send(:set_session, env, sid, data2)
463
+ _, session = store.send(:get_session, env, sid)
464
+ expect(session).to eq(data2)
465
+ end
466
+
467
+ it 'allows changing the session when the session has an expiry' do
468
+ env = { 'rack.session.options' => { expire_after: 60 } }
469
+ sid = 1234
470
+ store.stub(:redis).and_return(Redis.new)
471
+ data1 = { 'foo' => 'bar' }
472
+ store.send(:set_session, env, sid, data1)
473
+ data2 = { 'baz' => 'wat' }
474
+ store.send(:set_session, env, sid, data2)
475
+ _, session = store.send(:get_session, env, sid)
476
+ expect(session).to eq(data2)
477
+ end
478
+ end
453
479
  end
metadata CHANGED
@@ -1,110 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-session-store
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
5
- prerelease:
4
+ version: 0.6.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - Mathias Meyer
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-03-17 00:00:00.000000000 Z
11
+ date: 2014-04-04 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: redis
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: fakeredis
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rake
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rspec
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - ">="
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - ">="
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rubocop
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - ">="
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - ">="
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: simplecov
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - ">="
100
88
  - !ruby/object:Gem::Version
101
89
  version: '0'
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - ">="
108
95
  - !ruby/object:Gem::Version
109
96
  version: '0'
110
97
  description: A drop-in replacement for e.g. MemCacheStore to store Rails sessions
@@ -118,11 +105,11 @@ extra_rdoc_files:
118
105
  - AUTHORS.md
119
106
  - CONTRIBUTING.md
120
107
  files:
121
- - .gitignore
122
- - .rspec
123
- - .rubocop.yml
124
- - .simplecov
125
- - .travis.yml
108
+ - ".gitignore"
109
+ - ".rspec"
110
+ - ".rubocop.yml"
111
+ - ".simplecov"
112
+ - ".travis.yml"
126
113
  - AUTHORS.md
127
114
  - CHANGELOG.md
128
115
  - CONTRIBUTING.md
@@ -138,33 +125,27 @@ files:
138
125
  homepage: https://github.com/roidrage/redis-session-store
139
126
  licenses:
140
127
  - MIT
128
+ metadata: {}
141
129
  post_install_message:
142
130
  rdoc_options: []
143
131
  require_paths:
144
132
  - lib
145
133
  required_ruby_version: !ruby/object:Gem::Requirement
146
- none: false
147
134
  requirements:
148
- - - ! '>='
135
+ - - ">="
149
136
  - !ruby/object:Gem::Version
150
137
  version: '0'
151
- segments:
152
- - 0
153
- hash: 311231876661318648
154
138
  required_rubygems_version: !ruby/object:Gem::Requirement
155
- none: false
156
139
  requirements:
157
- - - ! '>='
140
+ - - ">="
158
141
  - !ruby/object:Gem::Version
159
142
  version: '0'
160
- segments:
161
- - 0
162
- hash: 311231876661318648
163
143
  requirements: []
164
144
  rubyforge_project:
165
- rubygems_version: 1.8.23
145
+ rubygems_version: 2.2.1
166
146
  signing_key:
167
- specification_version: 3
147
+ specification_version: 4
168
148
  summary: A drop-in replacement for e.g. MemCacheStore to store Rails sessions (and
169
149
  Rails sessions only) in Redis.
170
150
  test_files: []
151
+ has_rdoc: true