redis-stream 0.4.5 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/redis/stream/data_cache.rb +15 -4
- data/lib/redis/stream/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f717daecee4d177674a113217514c86d58fbb833fbd7e3a8751263f1c110b26a
|
4
|
+
data.tar.gz: a78aef2ebb19708c634c02e87b2039b1f1ceb7f3a04cc1aeecc929076130f35c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 380bfb8e1ea254d1e9cb3ab5d0c0367eaefe350671cc85ac0e7c34d9512965a9a00e7840745f759b45f172ad91d78db1e4774a39d542410f2b1cc6072a95be68
|
7
|
+
data.tar.gz: f0531ee5f9e2cc442ec9339c3935e0bd83c6930fe4e3476d843505c985f9d3f814e9ce44e584ed243f8cd4f7e27da45efad76605252ecf705cf01c898880a33d
|
data/Gemfile.lock
CHANGED
@@ -31,6 +31,14 @@ class Redis
|
|
31
31
|
@cache.delete(key)
|
32
32
|
end
|
33
33
|
|
34
|
+
def key_prefix=(prefix)
|
35
|
+
@key_prefix = prefix.downcase
|
36
|
+
end
|
37
|
+
|
38
|
+
def key_prefix
|
39
|
+
@key_prefix
|
40
|
+
end
|
41
|
+
|
34
42
|
def build_key(data)
|
35
43
|
key = ""
|
36
44
|
if data && data.include?('payload')
|
@@ -40,9 +48,9 @@ class Redis
|
|
40
48
|
end
|
41
49
|
|
42
50
|
if payload_data.include?("id")
|
43
|
-
action = payload_data["action"].downcase
|
44
51
|
id = payload_data["id"].downcase
|
45
|
-
key = "#{
|
52
|
+
key = "#{id}"
|
53
|
+
key = "#{@key_prefix}_#{key}" unless @key_prefix.nil? || @key_prefix&.empty?
|
46
54
|
end
|
47
55
|
raise "Empty cache key" if key.nil? || key&.empty?
|
48
56
|
key
|
@@ -87,10 +95,13 @@ class Redis
|
|
87
95
|
end
|
88
96
|
|
89
97
|
def get_from_cache(cache_key)
|
90
|
-
|
98
|
+
key?(cache_key)
|
91
99
|
|
92
100
|
data = self[cache_key]
|
93
|
-
|
101
|
+
if data&.key?('parent')
|
102
|
+
data = get_from_cache(self.build_key({'id' => data['parent']}))
|
103
|
+
end
|
104
|
+
|
94
105
|
data
|
95
106
|
end
|
96
107
|
end
|
data/lib/redis/stream/version.rb
CHANGED