redis-cacheable 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/redis_cacheable/version.rb +1 -1
- data/lib/redis_cacheable.rb +4 -0
- data/spec/lib/redis_cacheable_spec.rb +15 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9706cf90fd7bfd8c6276e7fb47c9d927ca1d4c42
|
4
|
+
data.tar.gz: 24e68ff93bf5d381c3bc96d133894a14cce2052d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a219636463b3d5684880ffba2a9ce08ad2459a6646324ed153a28b8ea8348a9b8dd7f909b3943cf99edceb4ee8a4d9a6413c71d32e69339b387d8dfe893818c
|
7
|
+
data.tar.gz: 8b24f33964a3860442851cf3e9aea69c0508740a8c77b97273a733a32c6fca6d352b55729b196b9bf8062587dd18ca9473f5c6f091e9cd83e125e22ea3102ea9
|
data/lib/redis_cacheable.rb
CHANGED
@@ -29,6 +29,10 @@ module RedisCacheable
|
|
29
29
|
include Connectable
|
30
30
|
|
31
31
|
module ClassMethods
|
32
|
+
def inherited(subclass)
|
33
|
+
subclass.instance_variable_set("@__redis_cache_key__", @__redis_cache_key__)
|
34
|
+
subclass.instance_variable_set("@__redis_cache_attrs__", @__redis_cache_attrs__)
|
35
|
+
end
|
32
36
|
|
33
37
|
# @param [Symbol || Proc] key used by redis.set method
|
34
38
|
# @example If Symbol, param is method name
|
@@ -25,6 +25,12 @@ class ProcKeyObject < CacheableObject
|
|
25
25
|
redis_key ->(object) { "object_#{object.id}" }
|
26
26
|
end
|
27
27
|
|
28
|
+
class InheritBase < CacheableObject
|
29
|
+
redis_key :name
|
30
|
+
end
|
31
|
+
|
32
|
+
class InheritChild < InheritBase; end
|
33
|
+
|
28
34
|
describe RedisCacheable do
|
29
35
|
describe "Object including RedisCacheable" do
|
30
36
|
describe "#cache_to_redis" do
|
@@ -54,6 +60,15 @@ describe RedisCacheable do
|
|
54
60
|
expect(ProcKeyObject.find_from_redis("object_1")).to eq({"id" => 1, "name" => "target"})
|
55
61
|
end
|
56
62
|
end
|
63
|
+
|
64
|
+
context "Inherit Test" do
|
65
|
+
subject { InheritChild.new(id: 1, name: "target").cache_to_redis }
|
66
|
+
|
67
|
+
it "use proc result as redis key" do
|
68
|
+
subject
|
69
|
+
expect(InheritChild.find_from_redis("target")).to eq({"id" => 1, "name" => "target"})
|
70
|
+
end
|
71
|
+
end
|
57
72
|
end
|
58
73
|
end
|
59
74
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis-cacheable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- joker1007
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -224,7 +224,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
224
224
|
version: '0'
|
225
225
|
requirements: []
|
226
226
|
rubyforge_project:
|
227
|
-
rubygems_version: 2.
|
227
|
+
rubygems_version: 2.2.2
|
228
228
|
signing_key:
|
229
229
|
specification_version: 4
|
230
230
|
summary: Concern style helper of caching object to Redis
|