redisize 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/redisize/version.rb +1 -1
- data/lib/redisize.rb +11 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f518b11244f545e6dbbd246a4953ee00e85315a9305200c52bfbc1d09359662c
|
4
|
+
data.tar.gz: 00f2823251a2351b81cda954070794ad6473fcc0ff5b234ff156f326b991ffa5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0041a03011688e066bc5725fc3cb78fb8c0b8bd32bd58b32560d3c9869382707932e5f31293691d21862fa82983bf40005ccbbacfc6fafadc12e046a10dde99
|
7
|
+
data.tar.gz: 316bcd2d0ea078e320188b630b79f9c85e351643acb026ed4b9c460d5f5eb33715373f9188a2578e8f5d0461bf9a16db977e653e08146a7e1d7c771fd936d592
|
data/lib/redisize/version.rb
CHANGED
data/lib/redisize.rb
CHANGED
@@ -133,7 +133,7 @@ module Redisize
|
|
133
133
|
end
|
134
134
|
|
135
135
|
def key_name_for model_name, attrs, type = "meta"
|
136
|
-
primary_key = model_name.constantize.primary_key
|
136
|
+
primary_key = model_name.constantize.primary_key || attrs.keys.first
|
137
137
|
[type, model_name, primary_key, attrs[primary_key].to_s]
|
138
138
|
end
|
139
139
|
|
@@ -244,7 +244,7 @@ module Redisize
|
|
244
244
|
# self -> model instance
|
245
245
|
def redisize_json scheme, &block
|
246
246
|
primary_key = self.class.primary_key
|
247
|
-
key = ["json", self.class.
|
247
|
+
key = ["json", self.class.polymorphic_base_name, primary_key, self[primary_key].to_s, scheme]
|
248
248
|
|
249
249
|
# binding.pry
|
250
250
|
redisize_cache_fetch(key, expires_in: 1.week) do
|
@@ -259,7 +259,7 @@ module Redisize
|
|
259
259
|
# self -> model instance
|
260
260
|
def deredisize_json scheme, &block
|
261
261
|
primary_key = self.class.primary_key
|
262
|
-
key = ["json", self.class.
|
262
|
+
key = ["json", self.class.polymorphic_base_name, primary_key, self[primary_key], scheme]
|
263
263
|
|
264
264
|
# binding.pry
|
265
265
|
Redisize.enqueue(:deredisize_json_metas, key)
|
@@ -267,13 +267,13 @@ module Redisize
|
|
267
267
|
|
268
268
|
# self -> model instance
|
269
269
|
def deredisize_model
|
270
|
-
Redisize.enqueue(:deredisize_model_metas, self.class.
|
270
|
+
Redisize.enqueue(:deredisize_model_metas, self.class.polymorphic_base_name)
|
271
271
|
end
|
272
272
|
|
273
273
|
# self -> model instance
|
274
274
|
def reredisize_instance
|
275
275
|
attrs = Redisize.as_json_for(self)
|
276
|
-
key = Redisize.key_name_for(self.class.
|
276
|
+
key = Redisize.key_name_for(self.class.polymorphic_base_name, attrs, "instance")
|
277
277
|
|
278
278
|
# binding.pry
|
279
279
|
redisize_cache_write(key, self, expires_in: 1000.years)
|
@@ -283,13 +283,17 @@ module Redisize
|
|
283
283
|
# self -> model instance
|
284
284
|
def deredisize_instance
|
285
285
|
attrs = Redisize.as_json_for(self)
|
286
|
-
key = Redisize.key_name_for(self.class.
|
286
|
+
key = Redisize.key_name_for(self.class.polymorphic_base_name, attrs, "instance")
|
287
287
|
|
288
288
|
# binding.pry
|
289
289
|
Redisize.enqueue(:deredisize_instance_metas, key)
|
290
290
|
end
|
291
291
|
|
292
292
|
module ClassMethods
|
293
|
+
def polymorphic_base_name
|
294
|
+
(base_class.to_s.split("::")[0...-1] + [polymorphic_name]).join("::")
|
295
|
+
end
|
296
|
+
|
293
297
|
# self -> model class
|
294
298
|
def redisize_sql &block
|
295
299
|
key = ["sql", self.name, self.primary_key, self.all.to_sql]
|
@@ -308,7 +312,7 @@ module Redisize
|
|
308
312
|
def redisize_model value, options = {}, &block
|
309
313
|
primary_key = options.fetch(:by_key, self.primary_key).to_s
|
310
314
|
key = ["instance", name, primary_key, value]
|
311
|
-
metakey = ["meta", self.class.
|
315
|
+
metakey = ["meta", self.class.polymorphic_base_name, primary_key, value]
|
312
316
|
|
313
317
|
# binding.pry
|
314
318
|
redisize_cache_fetch(key, expires_in: 1.week) do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redisize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel «Malo» Skrylev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|