kv_cache 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +10 -8
- data/lib/kv_cache/version.rb +1 -1
- data/spec/kv_store/store_spec.rb +14 -0
- 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: 07bcbff9052f9d411d0fd517ac6792d8156bda03
|
4
|
+
data.tar.gz: 5c5ee3df4b68ec5a91a9ff0b8b0038c8cd146e8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ade0ae3863fcae43c520d752da49b70a2c99336b2531b9b7632e96fd7ef66c0d4fb2bd3f80d2d6c35aa4c956c221a7258396905000da3a3a45efcdb30c216ead
|
7
|
+
data.tar.gz: 470eb49e7459fe054879f4ec60904906857ae0d39599d14bb2d4936762ab4b3cb4cb0e0696c69c1e4a905b90fae8102aede04a047575bc924d10887dc3f85307
|
data/README.md
CHANGED
@@ -20,16 +20,18 @@ Or install it yourself as:
|
|
20
20
|
## Usage
|
21
21
|
|
22
22
|
```
|
23
|
-
|
23
|
+
#config
|
24
|
+
opts = { :namespace => "app_v2", :compress => true }
|
25
|
+
KvCache::Store.storer = Dalli::Client.new('127.0.0.1:11211', opts)
|
24
26
|
|
27
|
+
#class
|
25
28
|
class City < ActiveRecord::Base
|
26
29
|
attr_accessible :name, :province
|
27
30
|
include KvCache
|
28
31
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
32
|
+
def of_province(prv)
|
33
|
+
Store.call("#City.of_province:#{prv}") {where(province: prv)}
|
34
|
+
end
|
33
35
|
after_save :kv_cache_reset
|
34
36
|
|
35
37
|
def kv_cache_reset
|
@@ -38,12 +40,12 @@ class City < ActiveRecord::Base
|
|
38
40
|
end
|
39
41
|
|
40
42
|
# some code
|
41
|
-
City.guangxi # first call will :
|
43
|
+
City.of_province("guangxi") # first call will :
|
42
44
|
# fecth from db
|
43
45
|
# select * from cities where province = 'guangxi'
|
44
|
-
cs = City.guangxi # will just return result above
|
46
|
+
cs = City.of_province("guangxi") # will just return result above
|
45
47
|
cs.first.save # will kv_cache_reset("guangxi")
|
46
|
-
City.guangxi # fecth from db again
|
48
|
+
City.of_province("guangxi") # fecth from db again
|
47
49
|
|
48
50
|
```
|
49
51
|
|
data/lib/kv_cache/version.rb
CHANGED
data/spec/kv_store/store_spec.rb
CHANGED
@@ -69,4 +69,18 @@ describe "KvCache::Store" do
|
|
69
69
|
res.should == 90
|
70
70
|
KvCache::Store.delete("hello")
|
71
71
|
end
|
72
|
+
|
73
|
+
it "#call auto Serializable" do
|
74
|
+
key = "Serializable"
|
75
|
+
KvCache::Store.delete(key)
|
76
|
+
res = KvCache::Store.call(key, 20) do
|
77
|
+
{ a: 9, b: 8}
|
78
|
+
end
|
79
|
+
res2 = KvCache::Store.call(key, 20) do
|
80
|
+
{ a: 9, b: 8}
|
81
|
+
end
|
82
|
+
res2.should be_kind_of(Hash)
|
83
|
+
res2[:b].should == 8
|
84
|
+
KvCache::Store.delete(key)
|
85
|
+
end
|
72
86
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kv_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
|
- azhao1981
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|