catch_cache 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/catch_cache/cache.rb +16 -0
- data/lib/catch_cache/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: aeae0742dd77cb93265bcae77e32f4d06154ab8e
|
4
|
+
data.tar.gz: 07f73a137ef2cc8e22a55a592433de21a83cc5f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67d510501ed20347dedb766b581ffc94313a0c70dd723891b27121598c2f5afa16607e273e3a4d097c55f7f889076d04531b1c3d17d009e2327a7ec97094380c
|
7
|
+
data.tar.gz: c22cf4f5ce38cd65f555195f8a12993897f2a299f7756ccd0b25f54927e9e2e54785c4bbe12f40bc843e0905ac1f4ffd380ed15e6c6232e0add916070b0e14a7
|
data/CHANGELOG.md
CHANGED
data/lib/catch_cache/cache.rb
CHANGED
@@ -18,6 +18,22 @@ module CatchCache
|
|
18
18
|
|
19
19
|
cache
|
20
20
|
end
|
21
|
+
|
22
|
+
def catch_then_cache(redis_key, &block)
|
23
|
+
redis = Redis.new
|
24
|
+
val = redis.get(redis_key)
|
25
|
+
|
26
|
+
# retrieve the cache with redis_key as its key
|
27
|
+
cache = JSON.parse(val.blank? ? "[]" : val)
|
28
|
+
|
29
|
+
if cache.blank?
|
30
|
+
timeline_logs = block.call
|
31
|
+
redis.set(redis_key, timeline_logs.to_json)
|
32
|
+
cache = JSON.parse(redis.get(redis_key))
|
33
|
+
end
|
34
|
+
|
35
|
+
cache
|
36
|
+
end
|
21
37
|
end
|
22
38
|
end
|
23
39
|
end
|
data/lib/catch_cache/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: catch_cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Neil Marion dela Cruz
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|