lru_redux 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/lib/lru_redux/cache19.rb +4 -1
- data/lib/lru_redux/version.rb +1 -1
- data/test/cache_test.rb +2 -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: b501fa162a36c12d13ff683ccbaa0e85ddda003d
|
4
|
+
data.tar.gz: 2888a33f2c15f078bec636d3782b8de0cb61f519
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5290cdf6e1b0a5014154891464790005625451db37c7959217da68b6f1f6a3ad41d46370bdcb734ed098cda4cb3945a12ea805284898c213c581a9f9b913d83c
|
7
|
+
data.tar.gz: 7b1cf05f55aa7f314ef9b4b346dca6d7ca20bf5458e893c4a32d4ae1fcb225a3bc6f2992cd1aee54e944f5e03e77cfeacecde69e46b711b272ebb1fe2648c0cd
|
data/README.md
CHANGED
@@ -95,6 +95,10 @@ lru_redux thread safe 2.480000 0.000000 2.480000 ( 2.488169)
|
|
95
95
|
|
96
96
|
## Changlog
|
97
97
|
|
98
|
+
###version 0.0.6 - 24-April-2013
|
99
|
+
|
100
|
+
- Fix bug in getset, overflow was not returning the yeilded val
|
101
|
+
|
98
102
|
###version 0.0.5 - 23-April-2013
|
99
103
|
|
100
104
|
- Added getset and fetch
|
data/lib/lru_redux/cache19.rb
CHANGED
@@ -23,8 +23,10 @@ class LruRedux::Cache
|
|
23
23
|
if found
|
24
24
|
@data[key] = value
|
25
25
|
else
|
26
|
-
@data[key] = yield
|
26
|
+
result = @data[key] = yield
|
27
|
+
# this may seem odd see: http://bugs.ruby-lang.org/issues/8312
|
27
28
|
@data.delete(@data.first[0]) if @data.length > @max_size
|
29
|
+
result
|
28
30
|
end
|
29
31
|
end
|
30
32
|
|
@@ -51,6 +53,7 @@ class LruRedux::Cache
|
|
51
53
|
def []=(key,val)
|
52
54
|
@data.delete(key)
|
53
55
|
@data[key] = val
|
56
|
+
# this may seem odd see: http://bugs.ruby-lang.org/issues/8312
|
54
57
|
@data.delete(@data.first[0]) if @data.length > @max_size
|
55
58
|
val
|
56
59
|
end
|
data/lib/lru_redux/version.rb
CHANGED
data/test/cache_test.rb
CHANGED
@@ -31,11 +31,11 @@ class CacheTest < MiniTest::Unit::TestCase
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def test_getset
|
34
|
-
@c.getset(:a){1}
|
34
|
+
assert_equal @c.getset(:a){1}, 1
|
35
35
|
@c.getset(:b){2}
|
36
36
|
assert_equal @c.getset(:a){11}, 1
|
37
37
|
@c.getset(:c){3}
|
38
|
-
@c.getset(:d){4}
|
38
|
+
assert_equal @c.getset(:d){4}, 4
|
39
39
|
|
40
40
|
assert_equal [[:d,4],[:c,3],[:a,1]], @c.to_a
|
41
41
|
end
|