redis_session 0.1.7 → 0.1.8
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 +7 -0
- data/lib/redis_session.rb +41 -10
- data/lib/redis_session/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7bc6ac0ea28ab8a6cdceaa73218b343fa95a100b
|
|
4
|
+
data.tar.gz: 562b87aca2b9f48e3206e2cf7a8a1b980906851f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4d36e9966929c830ceac87c0282eaa08cc90e44d48c6813bcdcd45959046110dfa6eccffd7a43f26b014edff6f3164461240c874ff186f96f8fb9b82aa873f1d
|
|
7
|
+
data.tar.gz: 8658e2b61cbc3684e5113a86443bd44921d94ef0774b92482bc464575e4bab4661c755bd568da0ce7a841a6fdf4940b2f1a814447d6190b68b5a546f25ea0ae6
|
data/README.md
CHANGED
|
@@ -22,6 +22,7 @@ request.
|
|
|
22
22
|
* Checking if key has a value
|
|
23
23
|
* Removing keys
|
|
24
24
|
* Changing the prefix using the prefix= method
|
|
25
|
+
* find key and value based on custom lookup
|
|
25
26
|
|
|
26
27
|
### Documentation
|
|
27
28
|
|
|
@@ -57,6 +58,12 @@ Example:
|
|
|
57
58
|
# it's alias to remove
|
|
58
59
|
|
|
59
60
|
puts 'still here' if session.key? 'key' # do we have the key ?
|
|
61
|
+
ret = session.scan_by do |x|
|
|
62
|
+
next unless x.kind_of? Hash
|
|
63
|
+
next unless x.key? :click
|
|
64
|
+
|
|
65
|
+
x[:click] == true
|
|
66
|
+
end
|
|
60
67
|
|
|
61
68
|
LICENSE
|
|
62
69
|
-------
|
data/lib/redis_session.rb
CHANGED
|
@@ -132,7 +132,9 @@ module Session
|
|
|
132
132
|
@redis.set(a_key, a_data)
|
|
133
133
|
end
|
|
134
134
|
true
|
|
135
|
-
rescue
|
|
135
|
+
rescue BaseConnectionError
|
|
136
|
+
raise
|
|
137
|
+
rescue Exception
|
|
136
138
|
false
|
|
137
139
|
end
|
|
138
140
|
|
|
@@ -150,7 +152,9 @@ module Session
|
|
|
150
152
|
a_key = make_key(key)
|
|
151
153
|
data = @redis.get(a_key)
|
|
152
154
|
data.nil? ? default : Marshal.load(data)
|
|
153
|
-
rescue
|
|
155
|
+
rescue BaseConnectionError
|
|
156
|
+
raise
|
|
157
|
+
rescue Exception
|
|
154
158
|
default
|
|
155
159
|
end
|
|
156
160
|
|
|
@@ -167,7 +171,9 @@ module Session
|
|
|
167
171
|
def expire(key, ttl)
|
|
168
172
|
a_key = make_key(key)
|
|
169
173
|
@redis.expire(a_key, ttl)
|
|
170
|
-
rescue
|
|
174
|
+
rescue BaseConnectionError
|
|
175
|
+
raise
|
|
176
|
+
rescue Exception
|
|
171
177
|
false
|
|
172
178
|
end
|
|
173
179
|
|
|
@@ -183,7 +189,10 @@ module Session
|
|
|
183
189
|
def ttl(key)
|
|
184
190
|
a_key = make_key(key)
|
|
185
191
|
@redis.ttl(a_key)
|
|
186
|
-
|
|
192
|
+
|
|
193
|
+
rescue BaseConnectionError
|
|
194
|
+
raise
|
|
195
|
+
rescue Exception
|
|
187
196
|
-1
|
|
188
197
|
end
|
|
189
198
|
|
|
@@ -199,7 +208,10 @@ module Session
|
|
|
199
208
|
def remove(key)
|
|
200
209
|
a_key = make_key(key)
|
|
201
210
|
@redis.del(a_key)
|
|
202
|
-
|
|
211
|
+
|
|
212
|
+
rescue BaseConnectionError
|
|
213
|
+
raise
|
|
214
|
+
rescue Exception
|
|
203
215
|
false
|
|
204
216
|
end
|
|
205
217
|
|
|
@@ -215,7 +227,10 @@ module Session
|
|
|
215
227
|
def key?(key)
|
|
216
228
|
a_key = make_key(key)
|
|
217
229
|
@redis.exists a_key
|
|
218
|
-
|
|
230
|
+
|
|
231
|
+
rescue BaseConnectionError
|
|
232
|
+
raise
|
|
233
|
+
rescue Exception
|
|
219
234
|
false
|
|
220
235
|
end
|
|
221
236
|
|
|
@@ -231,7 +246,10 @@ module Session
|
|
|
231
246
|
def value?(key)
|
|
232
247
|
a_key = make_key(key)
|
|
233
248
|
@redis.get(a_key) != nil
|
|
234
|
-
|
|
249
|
+
|
|
250
|
+
rescue BaseConnectionError
|
|
251
|
+
raise
|
|
252
|
+
rescue Exception
|
|
235
253
|
false
|
|
236
254
|
end
|
|
237
255
|
|
|
@@ -249,8 +267,19 @@ module Session
|
|
|
249
267
|
##
|
|
250
268
|
#
|
|
251
269
|
# scan for partial value in redis
|
|
252
|
-
# a
|
|
270
|
+
# Using a block you can create your own criteria for lookup:
|
|
271
|
+
#
|
|
272
|
+
# Example:
|
|
273
|
+
# let's say there is a key named "foo", and the value is a hash: {:click=>true, :reading=>0}
|
|
274
|
+
#
|
|
275
|
+
# ret = session.scan_by do |x|
|
|
276
|
+
# next unless x.kind_of? Hash
|
|
277
|
+
# next unless x.key? :click
|
|
278
|
+
#
|
|
279
|
+
# x[:click] == true
|
|
280
|
+
# end
|
|
253
281
|
#
|
|
282
|
+
# => {"foo"=>{:click=>true, :reading=>0}}
|
|
254
283
|
#
|
|
255
284
|
# If found return a hash of key => value
|
|
256
285
|
# If not found, return nil
|
|
@@ -272,8 +301,10 @@ module Session
|
|
|
272
301
|
|
|
273
302
|
{ key => value }
|
|
274
303
|
|
|
275
|
-
rescue
|
|
276
|
-
|
|
304
|
+
rescue BaseConnectionError
|
|
305
|
+
raise
|
|
306
|
+
rescue Exception #=> e
|
|
307
|
+
# puts "exception: #{e}\n#{e.backtrace.join("\n")}"
|
|
277
308
|
nil
|
|
278
309
|
end
|
|
279
310
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: redis_session
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ido Kanner
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-
|
|
11
|
+
date: 2016-10-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: redis
|