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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0df07a4472a3f8b5cd334dcef88c7d7ad3ea0464
4
- data.tar.gz: 041437f8d5faad17ae37f94752a608b411c986bb
3
+ metadata.gz: c2087b0c219ed59794b593652c47b8122b29b37d
4
+ data.tar.gz: e43bae4813128f1a0965c68cc383ea15ec62275d
5
5
  SHA512:
6
- metadata.gz: 11d693b71b8f42879fe28205989900e32e2a6afdf2e2a8ea2ad3d1f49dca81add60762afe2501d5d47eb948d7d1d2f4581c35f421904d88be97209a8fb08e6a4
7
- data.tar.gz: c9414176328c6dedc4e5e24a573abe887d646b8f0af5adf5799fd31dfb38c17970b001adf49d3504f1ed25c3981d98fd929fc378c4e50ff03ba929dbf0a0bc64
6
+ metadata.gz: 27d2a8e145cf28b8385f0b02122848c24698f09e4752ce8e4638349591a4f864d4a088d6137abefc9762910af98d3bc3381c4b460917ba0524a58a330ad3d58e
7
+ data.tar.gz: a7df8a0baa0b0b9c4502a6add6b01037ee1286400e06437a3fbae04fdc854498eb87bbe98d441ff8e65deb1b46eb8a00388731af97611358ac7e169f15ff2c8d
@@ -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 = Marshal::dump(value)
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 = Marshal::load(value) unless value == nil
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
@@ -1,3 +1,3 @@
1
1
  module CacheStoreRedis
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'
3
3
  end
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.0
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-24 00:00:00.000000000 Z
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