persistent-cache 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +30 -31
- data/lib/persistent-cache/version.rb +1 -1
- data/multidb +0 -0
- metadata +3 -2
data/README.md
CHANGED
@@ -1,11 +1,8 @@
|
|
1
1
|
# Persistent::Cache
|
2
2
|
|
3
|
-
Persistent cache behaves like a hash, with a sqlite3 storage back-end.
|
4
|
-
|
5
|
-
data remains fresh for-ever. If stale data is requested from the cache, nil is returned. Updates to the cache are
|
6
|
-
written to the sqlite3 storage, with SQL driver timeout set to 30 seconds. Data is marshalled before storage. If a key
|
7
|
-
is not found in the cache, nil is returned. Setting the value of a key in the cache to nil deletes the entry from the
|
8
|
-
sqlite database
|
3
|
+
Persistent cache behaves like a hash, with a sqlite3 storage back-end.
|
4
|
+
|
5
|
+
Values in the cache have a default freshness period of 15465600 ms. This can be configured in the cache initializer. Setting fresh = nil indicates that data remains fresh for-ever. If stale data is requested from the cache, nil is returned. Updates to the cache are written to the sqlite3 storage, with SQL driver timeout set to 30 seconds. Data is marshalled before storage. If a key is not found in the cache, nil is returned. Setting the value of a key in the cache to nil deletes the entry from the sqlite database.
|
9
6
|
|
10
7
|
This gem is sponsored by Hetzner (Pty) Ltd - http://hetzner.co.za
|
11
8
|
|
@@ -25,46 +22,48 @@ Or install it yourself as:
|
|
25
22
|
|
26
23
|
## Usage
|
27
24
|
|
28
|
-
cache = Persistent::Cache.new("/tmp/my-persistent-cache", 3600) # 1 hour freshness
|
25
|
+
cache = Persistent::Cache.new("/tmp/my-persistent-cache", 3600) # 1 hour freshness
|
29
26
|
|
30
|
-
cache["testkey"] = "testvalue"
|
31
|
-
puts cache["testkey"] # testvalue
|
27
|
+
cache["testkey"] = "testvalue"
|
28
|
+
puts cache["testkey"] # testvalue
|
32
29
|
|
33
|
-
cache["testkey"] = "newvalue"
|
34
|
-
puts cache["testkey"] # newvalue
|
30
|
+
cache["testkey"] = "newvalue"
|
31
|
+
puts cache["testkey"] # newvalue
|
35
32
|
|
36
|
-
cache["testkey"] = nil
|
37
|
-
puts cache["testkey"] #
|
33
|
+
cache["testkey"] = nil
|
34
|
+
puts cache["testkey"] #
|
38
35
|
|
39
|
-
cache["testkey"] = "one"
|
40
|
-
cache["testkey2"] = "two"
|
41
|
-
cache["testkey3"] = 3
|
36
|
+
cache["testkey"] = "one"
|
37
|
+
cache["testkey2"] = "two"
|
38
|
+
cache["testkey3"] = 3
|
42
39
|
|
43
|
-
cache.each do |key|
|
44
|
-
|
45
|
-
end
|
40
|
+
cache.each do |key|
|
41
|
+
puts "#{key} - #{cache[key]}"
|
42
|
+
end
|
46
43
|
|
47
|
-
#testkey - one
|
48
|
-
#testkey2 - two
|
49
|
-
#testkey3 - 3
|
44
|
+
#testkey - one
|
45
|
+
#testkey2 - two
|
46
|
+
#testkey3 - 3
|
50
47
|
|
51
|
-
puts cache.size # 3
|
48
|
+
puts cache.size # 3
|
52
49
|
|
53
|
-
puts cache.keys
|
54
|
-
#testkey
|
55
|
-
#testkey2
|
56
|
-
#testkey3
|
50
|
+
puts cache.keys
|
51
|
+
#testkey
|
52
|
+
#testkey2
|
53
|
+
#testkey3
|
57
54
|
|
58
|
-
cache.clear # []
|
55
|
+
cache.clear # []
|
59
56
|
|
60
|
-
puts cache.size #0
|
57
|
+
puts cache.size #0
|
61
58
|
|
62
|
-
cache = Persistent::Cache.new("/tmp/my-persistent-cache") # 15465600 (179 days) freshness
|
59
|
+
cache = Persistent::Cache.new("/tmp/my-persistent-cache") # 15465600 (179 days) freshness
|
63
60
|
|
64
|
-
cache = Persistent::Cache.new("/tmp/my-persistent-cache", nil) # for-ever fresh
|
61
|
+
cache = Persistent::Cache.new("/tmp/my-persistent-cache", nil) # for-ever fresh
|
65
62
|
|
66
63
|
Please send feedback and comments to the authors at:
|
64
|
+
|
67
65
|
Wynand van Dyk <wynand.van.dyk@hetzner.co.za>
|
66
|
+
|
68
67
|
Ernst van Graan <ernst.van.graan@hetzner.co.za>
|
69
68
|
|
70
69
|
## Contributing
|
data/multidb
ADDED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: persistent-cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-03-
|
13
|
+
date: 2013-03-19 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
@@ -61,6 +61,7 @@ files:
|
|
61
61
|
- Rakefile
|
62
62
|
- lib/persistent-cache.rb
|
63
63
|
- lib/persistent-cache/version.rb
|
64
|
+
- multidb
|
64
65
|
- persistent-cache.gemspec
|
65
66
|
- spec/persistent-cache_spec.rb
|
66
67
|
- spec/spec_helper.rb
|