cache_utils 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cache_utils/controller.rb +4 -4
- data/lib/cache_utils/model.rb +1 -1
- data/lib/cache_utils/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6357bd87358d5e6377f130af908ada99f8a051b8
|
4
|
+
data.tar.gz: f7ba12337e21f06898bf1ac7f140f89aae2ff5ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/cache_utils/model.rb
CHANGED
@@ -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
|
data/lib/cache_utils/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2017-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|