libcache 0.4 → 0.4.1
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 +5 -0
- data/lib/libcache/file_cache.rb +2 -2
- data/lib/libcache/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd7de71e70376b7fddaf6082f9136bc66e98e3e6
|
4
|
+
data.tar.gz: c349e392443f65fa59c5c55259af48c8afd10eec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6bc46327213cb45af8cd9890402e1936e7be7771b9f405cfb0693e91263c8815cef38df31e4f08af956bb7536a942e641d5982c0516d9a09be7296861642f7ac
|
7
|
+
data.tar.gz: a96427c27f0a4ae159be068a1b76636da792096b77bc48b731d9a72896cd1c75e9713090c54fd00d7a91a23e02c3651a84997ad97d5c88e9bae20b07a32e624d
|
data/README.md
CHANGED
@@ -40,6 +40,9 @@ sleep 4 # note that this is more than the expiry time
|
|
40
40
|
cache.get(1) # will return 105 as the data has been refreshed
|
41
41
|
cache.exists?(1) # will return true. if there is no set_refresh method provided then it will return false
|
42
42
|
|
43
|
+
cache.put("key123", [1,2,true])
|
44
|
+
pp cache.get("key123") # prints '[1, 2, true]' preserves type
|
45
|
+
|
43
46
|
# delete all data on exit of program
|
44
47
|
at_exit do
|
45
48
|
cache.invalidate_all
|
@@ -57,6 +60,8 @@ sleep 4 # note that this is more than the expiry time
|
|
57
60
|
cache.get(1) # will return 105 as the data has been refreshed
|
58
61
|
cache.exists?(1) # will return true. if there is no set_refresh method provided then it will return false
|
59
62
|
|
63
|
+
cache.put("key123", [1,2,true])
|
64
|
+
pp cache.get("key123") # prints '[1, 2, true]' preserves type
|
60
65
|
|
61
66
|
# delete all leftover files on exit of program
|
62
67
|
at_exit do
|
data/lib/libcache/file_cache.rb
CHANGED
@@ -21,8 +21,8 @@ class FileCache < Cache
|
|
21
21
|
# @param [String] key The key value used to identify an object in the cache
|
22
22
|
# @param [Object] value The object to be placed in the cache
|
23
23
|
def put(key, value)
|
24
|
-
raise
|
25
|
-
raise
|
24
|
+
raise ArgumentError unless key.is_a? String
|
25
|
+
raise ArgumentError unless key =~ /\A[a-zA-Z0-9_-]+\z/
|
26
26
|
@keys[key] = @keys.size.to_s
|
27
27
|
File.open(File.join(store, @keys[key]), 'w') do |f|
|
28
28
|
f.write(Marshal.dump(value))
|
data/lib/libcache/version.rb
CHANGED