cache_utils 0.2.5 → 0.2.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ac2bc2fd54f0bcbf716717041bb04abe85450a75
4
- data.tar.gz: 3470a817a32446a442f2fddbdd47b41de5afe485
3
+ metadata.gz: 6357bd87358d5e6377f130af908ada99f8a051b8
4
+ data.tar.gz: f7ba12337e21f06898bf1ac7f140f89aae2ff5ad
5
5
  SHA512:
6
- metadata.gz: f2ce47c515689c4ab832863077d0be742e336f00f9844683b1cd4de7e62a20e5b7237583710867e185e88634443bb58fc602d723a5fd4a762501b49b2b240fb2
7
- data.tar.gz: f93d76a4d9be66f0d61c45ecae56947af380f35dc3a30b0200eff12e1f7b625a91af0cfbc2e6650309b40348c843f51130ea9d877d6d13d4069bfc0bbc944fc5
6
+ metadata.gz: ccc0efa17022107f1a78b1ae19782eb713e7a3ddbe9522c2426d203d7c3605c71ed7850dd221fd571a568eebadaf18dd23f1465627b496c10872df14276bddf8
7
+ data.tar.gz: e72ded12c889e55534a92dc83edba81713d8f5e8f18c7bf714667a61dc1ff67249723f45cf6e0cd482bab22a56855a0d9a9ee3dcb5b2aad09d600cb24af46218
@@ -25,7 +25,7 @@ module CacheUtils
25
25
  end
26
26
 
27
27
  def get_cache(key)
28
- cached = $redis.get(key)
28
+ cached = ($redisr || $redis).get(key)
29
29
  if cached
30
30
  Appsignal.increment_counter('cache_hit', 1) if defined?(Appsignal)
31
31
  return cached
@@ -35,11 +35,11 @@ module CacheUtils
35
35
  end
36
36
 
37
37
  def set_cache(key, content)
38
- $redis.set(key, content)
38
+ ($redisw || $redis).set(key, content)
39
39
  end
40
40
 
41
41
  def fetch_cache(key, _options = nil)
42
- cached = $redis.get(key)
42
+ cached = ($redisr || $redis).get(key)
43
43
  if cached
44
44
  Appsignal.increment_counter('cache_hit', 1) if defined?(Appsignal)
45
45
  return cached
@@ -47,7 +47,7 @@ module CacheUtils
47
47
  Appsignal.increment_counter('cache_miss', 1) if defined?(Appsignal)
48
48
  if block_given?
49
49
  fresh = yield
50
- $redis.set(key, fresh)
50
+ ($redisw || $redis).set(key, fresh)
51
51
  fresh
52
52
  end
53
53
  end
@@ -19,7 +19,7 @@ module CacheUtils
19
19
  def purge_cache
20
20
  class_keys = self.class.cache_key
21
21
  class_keys += extra_class_key if respond_to?(:extra_class_key)
22
- $redis.del(*($redis.scan_each(match: custom_cache_key + '*').to_a + $redis.scan_each(match: class_keys + '*').to_a))
22
+ ($redisw || $redis).del(*(($redisr || $redis).scan_each(match: custom_cache_key + '*').to_a + ($redisr || $redis).scan_each(match: class_keys + '*').to_a))
23
23
  Appsignal.increment_counter('cache_purge', 1) if defined?(Appsignal)
24
24
  end
25
25
  end
@@ -1,3 +1,3 @@
1
1
  module CacheUtils
2
- VERSION = '0.2.5'.freeze
2
+ VERSION = '0.2.6'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cache_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michele Finotto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-10 00:00:00.000000000 Z
11
+ date: 2017-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler