hashcache 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/hashcache.rb +8 -3
- metadata +1 -1
data/lib/hashcache.rb
CHANGED
@@ -13,11 +13,16 @@ class HashCache
|
|
13
13
|
|
14
14
|
def read(item)
|
15
15
|
if @h.include? item then
|
16
|
-
val = @h[item]
|
16
|
+
val = @h[item]
|
17
|
+
@h.delete(item)
|
18
|
+
@h[item] = val
|
19
|
+
val
|
17
20
|
else
|
18
|
-
|
21
|
+
val = yield
|
22
|
+
@h[item] = val
|
19
23
|
@h.shift if @h.length > @size
|
20
|
-
|
24
|
+
val
|
25
|
+
end
|
21
26
|
end
|
22
27
|
|
23
28
|
def reset
|