lru_redux 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/lib/lru_redux/cache.rb +8 -3
- data/lib/lru_redux/version.rb +1 -1
- data/test/cache_test.rb +9 -0
- 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: 78eae8fc324be527cb810fa0346fc009f4bee816
|
4
|
+
data.tar.gz: dcc9a4af9681636d338ebdeca2e2eef99152dd06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c55ef7737644cdc0bdc25abbb3d4756eeef996e179ec31871f22925abd370c43e6070b513cf6bbc82afb31782430534111a32f2fab31a576d0892b8fef87241
|
7
|
+
data.tar.gz: f11d972cd374a60163cf0430d6727755bb652a490fec1a0b36de96045faf35c5b7fab45ef8598f3a3223253141f851135e86cb23c741a6eee64bff854172f1b4
|
data/README.md
CHANGED
@@ -69,3 +69,9 @@ lru_redux thread safe 2.750000 0.000000 2.750000 ( 2.752526)
|
|
69
69
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
70
70
|
4. Push to the branch (`git push origin my-new-feature`)
|
71
71
|
5. Create new Pull Request
|
72
|
+
|
73
|
+
## Changlog
|
74
|
+
|
75
|
+
###verson 0.0.2 - 23-April-2013
|
76
|
+
|
77
|
+
- Added .clear method
|
data/lib/lru_redux/cache.rb
CHANGED
@@ -3,8 +3,8 @@ class LruRedux::Cache
|
|
3
3
|
# for high efficiency nodes in double linked list are stored in arrays
|
4
4
|
# [prev,key,val,next]
|
5
5
|
|
6
|
-
def initialize(
|
7
|
-
@
|
6
|
+
def initialize(max_size)
|
7
|
+
@max_size = max_size
|
8
8
|
@data = {}
|
9
9
|
@head = nil
|
10
10
|
@tail = nil
|
@@ -62,6 +62,11 @@ class LruRedux::Cache
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
+
def clear
|
66
|
+
@data.clear
|
67
|
+
@head = @tail = nil
|
68
|
+
end
|
69
|
+
|
65
70
|
def count
|
66
71
|
@data.count
|
67
72
|
end
|
@@ -108,7 +113,7 @@ class LruRedux::Cache
|
|
108
113
|
end
|
109
114
|
|
110
115
|
def pop_tail
|
111
|
-
if @data.length == @
|
116
|
+
if @data.length == @max_size
|
112
117
|
@data.delete(@tail.key)
|
113
118
|
@tail = @tail.next
|
114
119
|
@tail.prev = nil
|
data/lib/lru_redux/version.rb
CHANGED
data/test/cache_test.rb
CHANGED