cache_store_redis 2.0.0 → 2.1.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/lib/cache_store_redis/redis_cache_store.rb +8 -2
- data/lib/cache_store_redis/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e83f4625b064a5084ac1a7f4b74062311a471901a50a43e529b78cf2c9e0d44
|
4
|
+
data.tar.gz: 5e6c6d90998cd4650c62653b1b8aff2f3d0f6711d9c7123168a87500b394de22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00af5701b9b7ea343346fdc89b9273887041ea6c68fea7bc2c3188f6b232c238a24d76db9890c7c5102fc3f48d7641abe628b4b0c11c46b614684f621491b12f
|
7
|
+
data.tar.gz: 1cd61ba1fb82743666ded174096aa55b7ce494c1dd0ee80016b95ff495e9069d261e5e8697db65d391dee59ca6b8a458b648a94b2004d575a68b370a848eb9e6
|
@@ -1,5 +1,8 @@
|
|
1
1
|
# This class is used to implement a redis cache store.
|
2
2
|
class RedisCacheStore
|
3
|
+
# Default expiry time if not provided. (1 hour)
|
4
|
+
DEFAULT_TTL = 3_600
|
5
|
+
|
3
6
|
def initialize(namespace = nil, config = nil)
|
4
7
|
@connection_pool = RedisConnectionPool.new(config)
|
5
8
|
|
@@ -59,7 +62,7 @@ class RedisCacheStore
|
|
59
62
|
# @param key [String] This is the unique key to reference the value being set within this cache store.
|
60
63
|
# @param value [Object] This is the value to set within this cache store.
|
61
64
|
# @param expires_in [Integer] This is the number of seconds from the current time that this value should expire.
|
62
|
-
def set(key, value, expires_in =
|
65
|
+
def set(key, value, expires_in = DEFAULT_TTL)
|
63
66
|
k = build_key(key)
|
64
67
|
|
65
68
|
v = if value.nil? || (value.is_a?(String) && value.strip.empty?)
|
@@ -68,11 +71,14 @@ class RedisCacheStore
|
|
68
71
|
serialize(value)
|
69
72
|
end
|
70
73
|
|
74
|
+
expiry_int = Integer(expires_in)
|
75
|
+
expire_value = expiry_int.positive? ? expiry_int : DEFAULT_TTL
|
76
|
+
|
71
77
|
with_client do |client|
|
72
78
|
client.multi do
|
73
79
|
client.set(k, v)
|
74
80
|
|
75
|
-
client.expire(k,
|
81
|
+
client.expire(k, expire_value)
|
76
82
|
end
|
77
83
|
end
|
78
84
|
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: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- vaughanbrittonsage
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|