hashcache 0.1.8 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/hashcache.rb +15 -11
- metadata +2 -2
data/lib/hashcache.rb
CHANGED
@@ -17,18 +17,22 @@ class HashCache
|
|
17
17
|
if @h.include? item then
|
18
18
|
self.refresh item
|
19
19
|
else
|
20
|
-
|
21
|
-
read_file item
|
22
|
-
else
|
23
|
-
val = yield
|
24
|
-
@h[item] = val
|
25
|
-
@h.shift if @h.length > @size
|
26
|
-
write_file(item, val) if @file_cache == true
|
27
|
-
val
|
28
|
-
end
|
20
|
+
self.write item
|
29
21
|
end
|
30
22
|
end
|
31
23
|
|
24
|
+
def write(item)
|
25
|
+
if @file_cache == true and File.exists? @file_path + '/' + item then
|
26
|
+
read_file item
|
27
|
+
else
|
28
|
+
val = yield
|
29
|
+
@h[item] = val
|
30
|
+
@h.shift if @h.length > @size
|
31
|
+
write_file(item, val) if @file_cache == true
|
32
|
+
val
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
32
36
|
def refresh(item)
|
33
37
|
val = @h[item]
|
34
38
|
@h.delete item
|
@@ -50,6 +54,6 @@ class HashCache
|
|
50
54
|
|
51
55
|
def write_file(item, obj)
|
52
56
|
File.open(@file_path + '/' + item, 'w+') {|f| Marshal.dump(obj, f) }
|
53
|
-
end
|
54
|
-
|
57
|
+
end
|
58
|
+
|
55
59
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hashcache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors: []
|
7
7
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-08-28 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|