rack-redic 2.0.1 → 2.2.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/README.md +113 -0
- metadata +24 -113
- data/README.org +0 -105
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8f406be5199f71812675e4b268718cec8feb6e04b52920c581b695f5e54f148
|
4
|
+
data.tar.gz: 43cb8d93b4994fb82ee47e87b3ea7df9dd74694fbd15cea7218b75b20415a5a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 159b1b037606983df8ab16e75278ce470db0fc5092e9d430a5defd3ca4d937cabec4934e335091ad258b333af8faed2624b7cbef7281ecc7f22b2f9233150d40
|
7
|
+
data.tar.gz: 9613b147b2fad92ce618f920ca57f806e829178152e6302275f536c31ff26b64908deb8002f9c946b41b192bbf128d1ab9cf7e43b85d66cfaed3bdd2b7dab7d3
|
data/README.md
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
# Rack::Session::Redic
|
2
|
+
|
3
|
+
`Rack::Session::Redic` provides simple cookie based session management. Session
|
4
|
+
data is stored in [Redis](redis) via the [Redic](redic) gem. The corresponding
|
5
|
+
session key is maintained in the cookie.
|
6
|
+
|
7
|
+
Options include:
|
8
|
+
|
9
|
+
- `:marshaller` - You may optionally supply the class/module you would like to
|
10
|
+
use when marshalling objects in and out of Redis. All that is required is that
|
11
|
+
this class respond to the `load` and `dump` methods, returning the session hash
|
12
|
+
and a string respectively.
|
13
|
+
- `:url` - Additionally, you may pass in the URL for your Redis server. The
|
14
|
+
default URL is fetched from the `ENV` as `REDIS_URL` in keeping with Heroku and
|
15
|
+
others' practices.
|
16
|
+
- `:expire_after` - Finally, expiration will be passed to the Redis server via
|
17
|
+
the 'EX' option on 'SET'. Expiration should be in seconds, just like Rack's
|
18
|
+
default handling of the `:expire_after` option. This option will refresh the
|
19
|
+
expiration set in Redis with each request.
|
20
|
+
|
21
|
+
Any other options will get passed to `Rack::Session::Abstract::Persisted`.
|
22
|
+
|
23
|
+
## Installation
|
24
|
+
|
25
|
+
Add this line to your application's Gemfile or gems.rb file:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
gem 'rack-redic', require: 'rack/session/redic'
|
29
|
+
```
|
30
|
+
|
31
|
+
And then execute:
|
32
|
+
|
33
|
+
```sh
|
34
|
+
bundle
|
35
|
+
```
|
36
|
+
|
37
|
+
Or install it yourself as:
|
38
|
+
|
39
|
+
```sh
|
40
|
+
gem install rack-redic
|
41
|
+
```
|
42
|
+
|
43
|
+
## Usage
|
44
|
+
|
45
|
+
Anywhere in your Rack application just add:
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
# Most basic usage.
|
49
|
+
use Rack::Session::Redic
|
50
|
+
|
51
|
+
# Optionally pass in a marshaller.
|
52
|
+
use Rack::Session::Redic, marshaller: Oj
|
53
|
+
|
54
|
+
# And/or pass in the URL of your Redis server.
|
55
|
+
use Rack::Session::Redic, marshaller: Oj, url: 'redis://host:port'
|
56
|
+
|
57
|
+
# And/or pass in the expiration. (1_800 is 30 minutes in seconds)
|
58
|
+
use Rack::Session::Redic, marshaller: Oj, url: 'redis://host:port', expire_after: 1_800
|
59
|
+
```
|
60
|
+
|
61
|
+
## Custom Marshallers
|
62
|
+
|
63
|
+
Since the class/module passed as `:marshaller` only needs to respond to the
|
64
|
+
methods `load` and `dump`, you can create any kind of marshaller you would like.
|
65
|
+
I've included examples for MessagePack and Oj here as reference.
|
66
|
+
|
67
|
+
### [MessagePack](msgpack)
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
require 'msgpack'
|
71
|
+
|
72
|
+
MessagePack::DefaultFactory.register_type(0x00, Symbol)
|
73
|
+
|
74
|
+
module MessagePackMarshaller
|
75
|
+
def self.dump(object)
|
76
|
+
MessagePack.pack(object)
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.load(string)
|
80
|
+
MessagePack.unpack(string)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
```
|
84
|
+
|
85
|
+
Then, while adding it your Rack application.
|
86
|
+
|
87
|
+
```ruby
|
88
|
+
use Rack::Session::Redic, marshaller: MessagePackMarshaller
|
89
|
+
```
|
90
|
+
|
91
|
+
**NOTE:** MessagePack [serializes symbols as strings by default](symbols) so I
|
92
|
+
suggest customizing that behavior per their instructions. You can [read more
|
93
|
+
about MessagePack's extension formats here](extensions).
|
94
|
+
|
95
|
+
### [Oj](oj)
|
96
|
+
|
97
|
+
Oj responds to `load` and `dump` by default so there's no adapter module needed.
|
98
|
+
|
99
|
+
```ruby
|
100
|
+
use Rack::Session::Redic, marshaller: Oj
|
101
|
+
```
|
102
|
+
|
103
|
+
## License
|
104
|
+
|
105
|
+
The gem is available as open source under the terms of the [MIT
|
106
|
+
License](http://opensource.org/licenses/MIT).
|
107
|
+
|
108
|
+
[extensions]: https://github.com/msgpack/msgpack/blob/master/spec.md#types-extension-type
|
109
|
+
[msgpack]: https://github.com/msgpack/msgpack-ruby
|
110
|
+
[oj]: https://github.com/ohler55/oj
|
111
|
+
[redic]: https://github.com/amakawa/redic
|
112
|
+
[redis]: http://redis.io
|
113
|
+
[symbols]: https://github.com/msgpack/msgpack-ruby#serializing-and-deserializing-symbols
|
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: 2.0
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evan Lecklider
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -16,120 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: redic
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
19
|
+
version: 2.0.0
|
20
|
+
- - "<"
|
32
21
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
22
|
+
version: '4'
|
34
23
|
type: :runtime
|
35
24
|
prerelease: false
|
36
25
|
version_requirements: !ruby/object:Gem::Requirement
|
37
26
|
requirements:
|
38
27
|
- - ">="
|
39
28
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
41
|
-
-
|
42
|
-
name: bundler
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
29
|
+
version: 2.0.0
|
30
|
+
- - "<"
|
46
31
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
32
|
+
version: '4'
|
55
33
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
34
|
+
name: rack-session
|
57
35
|
requirement: !ruby/object:Gem::Requirement
|
58
36
|
requirements:
|
59
37
|
- - ">="
|
60
38
|
- !ruby/object:Gem::Version
|
61
39
|
version: '0'
|
62
|
-
type: :
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rake
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: rubocop
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: rubocop-minitest
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: rubocop-packaging
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - ">="
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - ">="
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '0'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: rubocop-performance
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - ">="
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '0'
|
132
|
-
type: :development
|
40
|
+
type: :runtime
|
133
41
|
prerelease: false
|
134
42
|
version_requirements: !ruby/object:Gem::Requirement
|
135
43
|
requirements:
|
@@ -137,19 +45,19 @@ dependencies:
|
|
137
45
|
- !ruby/object:Gem::Version
|
138
46
|
version: '0'
|
139
47
|
- !ruby/object:Gem::Dependency
|
140
|
-
name:
|
48
|
+
name: redic
|
141
49
|
requirement: !ruby/object:Gem::Requirement
|
142
50
|
requirements:
|
143
|
-
- - "
|
51
|
+
- - "~>"
|
144
52
|
- !ruby/object:Gem::Version
|
145
|
-
version: '
|
146
|
-
type: :
|
53
|
+
version: '1'
|
54
|
+
type: :runtime
|
147
55
|
prerelease: false
|
148
56
|
version_requirements: !ruby/object:Gem::Requirement
|
149
57
|
requirements:
|
150
|
-
- - "
|
58
|
+
- - "~>"
|
151
59
|
- !ruby/object:Gem::Version
|
152
|
-
version: '
|
60
|
+
version: '1'
|
153
61
|
description: Rack::Session in Redis via Redic
|
154
62
|
email:
|
155
63
|
- evan@lecklider.com
|
@@ -158,15 +66,18 @@ extensions: []
|
|
158
66
|
extra_rdoc_files: []
|
159
67
|
files:
|
160
68
|
- LICENSE.txt
|
161
|
-
- README.
|
69
|
+
- README.md
|
162
70
|
- lib/rack/session/redic.rb
|
163
71
|
homepage: https://github.com/evanleck/rack-redic
|
164
72
|
licenses:
|
165
73
|
- MIT
|
166
74
|
metadata:
|
167
75
|
bug_tracker_uri: https://github.com/evanleck/rack-redic/issues
|
76
|
+
changelog_uri: https://github.com/evanleck/rack-redic/blob/main/CHANGELOG.md
|
77
|
+
homepage_uri: https://github.com/evanleck/rack-redic
|
78
|
+
rubygems_mfa_required: 'true'
|
168
79
|
source_code_uri: https://github.com/evanleck/rack-redic
|
169
|
-
post_install_message:
|
80
|
+
post_install_message:
|
170
81
|
rdoc_options: []
|
171
82
|
require_paths:
|
172
83
|
- lib
|
@@ -181,8 +92,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
92
|
- !ruby/object:Gem::Version
|
182
93
|
version: '0'
|
183
94
|
requirements: []
|
184
|
-
rubygems_version: 3.
|
185
|
-
signing_key:
|
95
|
+
rubygems_version: 3.4.10
|
96
|
+
signing_key:
|
186
97
|
specification_version: 4
|
187
98
|
summary: Rack::Session in Redis via Redic
|
188
99
|
test_files: []
|
data/README.org
DELETED
@@ -1,105 +0,0 @@
|
|
1
|
-
* Rack::Session::Redic
|
2
|
-
|
3
|
-
=Rack::Session::Redic= provides simple cookie based session management. Session
|
4
|
-
data is stored in [[http://redis.io][Redis]] via the [[https://github.com/amakawa/redic][Redic]] gem. The corresponding session key is
|
5
|
-
maintained in the cookie.
|
6
|
-
|
7
|
-
Options include:
|
8
|
-
|
9
|
-
- =:marshaller= - You may optionally supply the class/module you would
|
10
|
-
like to use when marshalling objects in and out of Redis. All that is
|
11
|
-
required is that this class respond to the =load= and =dump= methods,
|
12
|
-
returning the session hash and a string respectively.
|
13
|
-
- =:url= - Additionally, you may pass in the URL for your Redis server.
|
14
|
-
The default URL is fetched from the =ENV= as =REDIS_URL= in keeping
|
15
|
-
with Heroku and others' practices.
|
16
|
-
- =:expire_after= - Finally, expiration will be passed to the Redis
|
17
|
-
server via the 'EX' option on 'SET'. Expiration should be in seconds,
|
18
|
-
just like Rack's default handling of the =:expire_after= option. This
|
19
|
-
option will refresh the expiration set in Redis with each request.
|
20
|
-
|
21
|
-
Any other options will get passed to =Rack::Session::Abstract::Persisted=.
|
22
|
-
|
23
|
-
** Installation
|
24
|
-
|
25
|
-
Add this line to your application's Gemfile or gems.rb file:
|
26
|
-
|
27
|
-
#+begin_src ruby
|
28
|
-
gem 'rack-redic', require: 'rack/session/redic'
|
29
|
-
#+end_src
|
30
|
-
|
31
|
-
And then execute:
|
32
|
-
|
33
|
-
#+begin_src sh
|
34
|
-
bundle
|
35
|
-
#+end_src
|
36
|
-
|
37
|
-
Or install it yourself as:
|
38
|
-
|
39
|
-
#+begin_src sh
|
40
|
-
gem install rack-redic
|
41
|
-
#+end_src
|
42
|
-
|
43
|
-
** Usage
|
44
|
-
|
45
|
-
Anywhere in your Rack application just add:
|
46
|
-
|
47
|
-
#+begin_src ruby
|
48
|
-
# Most basic usage.
|
49
|
-
use Rack::Session::Redic
|
50
|
-
|
51
|
-
# Optionally pass in a marshaller.
|
52
|
-
use Rack::Session::Redic, marshaller: Oj
|
53
|
-
|
54
|
-
# And/or pass in the URL of your Redis server.
|
55
|
-
use Rack::Session::Redic, marshaller: Oj, url: 'redis://host:port'
|
56
|
-
|
57
|
-
# And/or pass in the expiration. (1_800 is 30 minutes in seconds)
|
58
|
-
use Rack::Session::Redic, marshaller: Oj, url: 'redis://host:port', expire_after: 1_800
|
59
|
-
#+end_src
|
60
|
-
|
61
|
-
** Custom Marshallers
|
62
|
-
|
63
|
-
Since the class/module passed as =:marshaller= only needs to respond to the
|
64
|
-
methods =load= and =dump=, you can create any kind of marshaller you would like.
|
65
|
-
I've included examples for MessagePack and Oj here as reference.
|
66
|
-
|
67
|
-
*** [[https://github.com/msgpack/msgpack-ruby][MessagePack]]
|
68
|
-
|
69
|
-
#+begin_src ruby
|
70
|
-
require 'msgpack'
|
71
|
-
|
72
|
-
MessagePack::DefaultFactory.register_type(0x00, Symbol)
|
73
|
-
|
74
|
-
module MessagePackMarshaller
|
75
|
-
def self.dump(object)
|
76
|
-
MessagePack.pack(object)
|
77
|
-
end
|
78
|
-
|
79
|
-
def self.load(string)
|
80
|
-
MessagePack.unpack(string)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
#+end_src
|
84
|
-
|
85
|
-
Then, while adding it your Rack application.
|
86
|
-
|
87
|
-
#+BEGIN_SRC ruby
|
88
|
-
use Rack::Session::Redic, marshaller: MessagePackMarshaller
|
89
|
-
#+END_SRC
|
90
|
-
|
91
|
-
*NOTE:* MessagePack [[https://github.com/msgpack/msgpack-ruby#serializing-and-deserializing-symbols][serializes symbols as strings by default]] so I suggest
|
92
|
-
customizing that behavior per their instructions. You can [[https://github.com/msgpack/msgpack/blob/master/spec.md#types-extension-type][read more about
|
93
|
-
MessagePack's extension formats here]].
|
94
|
-
|
95
|
-
*** [[https://github.com/ohler55/oj][Oj]]
|
96
|
-
|
97
|
-
Oj responds to =load= and =dump= by default so there's no adapter module needed.
|
98
|
-
|
99
|
-
#+begin_src ruby
|
100
|
-
use Rack::Session::Redic, marshaller: Oj
|
101
|
-
#+end_src
|
102
|
-
|
103
|
-
** License
|
104
|
-
|
105
|
-
The gem is available as open source under the terms of the [[http://opensource.org/licenses/MIT][MIT License]].
|