basiccache 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/basiccache.gemspec +1 -1
- data/lib/basiccache/caches/timecache.rb +7 -2
- 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: ef69d2ee09a138990c7796e66ce25e985b1c617e
|
4
|
+
data.tar.gz: bf2dbe030e3c91ccc7e7aac1b3425d15aa1e5e34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a9f861cc343763a596113f1b184f62b1106f94d33112b014fbf0e670e351f0694798d7131e6ab99b2f15e309a9d28aed45fb8db37ad2c23b4bce4888d562a55
|
7
|
+
data.tar.gz: 70752ee625e1b072ae3d938460f522498413cdaf3833fa243374b2df9ab4583339a75880029127af25f2c9d3f530de5dd60a63ff270198de87059888cdc12866
|
data/basiccache.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'basiccache'
|
3
|
-
s.version = '0.2.
|
3
|
+
s.version = '0.2.1'
|
4
4
|
s.date = Time.now.strftime("%Y-%m-%d")
|
5
5
|
s.summary = 'Provides a minimal key/value caching layer'
|
6
6
|
s.description = "Allows an application to dynamically cache values and retrieve them later"
|
@@ -34,8 +34,13 @@ module BasicCache
|
|
34
34
|
def cache(key = nil, &code)
|
35
35
|
key ||= BasicCache.caller_name
|
36
36
|
key = key.to_sym
|
37
|
-
|
38
|
-
|
37
|
+
if include? key
|
38
|
+
@store[key].value
|
39
|
+
else
|
40
|
+
value = code.call
|
41
|
+
@store[key] = TimeCacheItem.new Time.now, value
|
42
|
+
value
|
43
|
+
end
|
39
44
|
end
|
40
45
|
|
41
46
|
##
|