cache_store_redis 2.0.0 → 2.1.0

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
  SHA256:
3
- metadata.gz: 5bb583829e24ed293d2837d63176cd5721cf33891196762f790297781c56e89e
4
- data.tar.gz: bd9fad442f4c769a3fecfb15708f26a42e2b9d1df6da2fe84db08cf3080ddfcf
3
+ metadata.gz: 7e83f4625b064a5084ac1a7f4b74062311a471901a50a43e529b78cf2c9e0d44
4
+ data.tar.gz: 5e6c6d90998cd4650c62653b1b8aff2f3d0f6711d9c7123168a87500b394de22
5
5
  SHA512:
6
- metadata.gz: 4d4af265afe33f984b2995ff63909da9b6469a209bdd681b7797c79bfa007b9b1bdcb0f05ff859f8cf64e53a1973b5281eee573f224f819313efde131d72c91f
7
- data.tar.gz: df1267a5783d9e47f6d042eb4914a0f717f3dd3b9834b7ac4b8907f9d6ba504ceaed43ae24ed1521c0bdb644ace8f1b46c1afd1509c92c8daa5531447db86f7e
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 = 3_600)
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, expires_in) if expires_in.positive?
81
+ client.expire(k, expire_value)
76
82
  end
77
83
  end
78
84
  end
@@ -1,3 +1,3 @@
1
1
  module CacheStoreRedis
2
- VERSION = '2.0.0'
2
+ VERSION = '2.1.0'
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: 2.0.0
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-01-24 00:00:00.000000000 Z
11
+ date: 2019-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler