cache_store_redis 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cache_store_redis.rb +22 -2
- data/lib/cache_store_redis/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2087b0c219ed59794b593652c47b8122b29b37d
|
4
|
+
data.tar.gz: e43bae4813128f1a0965c68cc383ea15ec62275d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27d2a8e145cf28b8385f0b02122848c24698f09e4752ce8e4638349591a4f864d4a088d6137abefc9762910af98d3bc3381c4b460917ba0524a58a330ad3d58e
|
7
|
+
data.tar.gz: a7df8a0baa0b0b9c4502a6add6b01037ee1286400e06437a3fbae04fdc854498eb87bbe98d441ff8e65deb1b46eb8a00388731af97611358ac7e169f15ff2c8d
|
data/lib/cache_store_redis.rb
CHANGED
@@ -7,6 +7,10 @@ require 'securerandom'
|
|
7
7
|
class RedisCacheStore
|
8
8
|
|
9
9
|
def initialize(namespace = nil, config = nil)
|
10
|
+
if RUBY_PLATFORM != 'java'
|
11
|
+
require 'oj'
|
12
|
+
end
|
13
|
+
|
10
14
|
@namespace = namespace
|
11
15
|
if config == nil
|
12
16
|
@client = Redis.new
|
@@ -43,7 +47,7 @@ class RedisCacheStore
|
|
43
47
|
k = build_key(key)
|
44
48
|
|
45
49
|
if value != nil
|
46
|
-
v =
|
50
|
+
v = serialize(value)
|
47
51
|
end
|
48
52
|
|
49
53
|
@client.set(k, v)
|
@@ -65,7 +69,7 @@ class RedisCacheStore
|
|
65
69
|
k = build_key(key)
|
66
70
|
|
67
71
|
value = @client.get(k)
|
68
|
-
value =
|
72
|
+
value = deserialize(value) unless value == nil
|
69
73
|
|
70
74
|
if value.nil? && block_given?
|
71
75
|
value = yield
|
@@ -103,6 +107,22 @@ class RedisCacheStore
|
|
103
107
|
|
104
108
|
private
|
105
109
|
|
110
|
+
def serialize(object)
|
111
|
+
if RUBY_PLATFORM == 'java'
|
112
|
+
Marshal::dump(value)
|
113
|
+
else
|
114
|
+
OJ.dump(value)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def deserialize(object)
|
119
|
+
if RUBY_PLATFORM == 'java'
|
120
|
+
Marshal::load(value)
|
121
|
+
else
|
122
|
+
OJ.load(value)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
106
126
|
def build_key(key)
|
107
127
|
k = ''
|
108
128
|
if @namespace != nil
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cache_store_redis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- vaughanbrittonsage
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: oj
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
description: This is the redis cache_store implementation.
|
84
98
|
email:
|
85
99
|
- vaughan.britton@sage.com
|