duality 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/HISTORY.md +5 -2
- data/lib/duality.rb +10 -25
- metadata +1 -1
data/HISTORY.md
CHANGED
data/lib/duality.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'timeout'
|
2
2
|
class Duality
|
3
3
|
|
4
|
-
VERSION = "0.0.
|
4
|
+
VERSION = "0.0.3"
|
5
5
|
#DEFAULT_TIMEOUT=1
|
6
6
|
@@fast, @@slow = nil
|
7
7
|
|
@@ -29,14 +29,9 @@ class Duality
|
|
29
29
|
def set key, value
|
30
30
|
fast = Thread.new { @fast.set(key, value) }
|
31
31
|
slow = Thread.new { @slow.set(key, value) }
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
while (fast.alive? || slow.alive?) do
|
36
|
-
raise CacheTimeout if current == timeout
|
37
|
-
sleep 0.1
|
38
|
-
current = current + 1
|
39
|
-
end
|
32
|
+
fast.join(1)
|
33
|
+
slow.join(1)
|
34
|
+
(fast.status == false && slow.status == false)
|
40
35
|
end
|
41
36
|
alias :save :set
|
42
37
|
|
@@ -44,14 +39,9 @@ class Duality
|
|
44
39
|
def delete key
|
45
40
|
fast = Thread.new { @fast.delete(key) }
|
46
41
|
slow = Thread.new { @slow.delete(key) }
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
while (fast.alive? || slow.alive?) do
|
51
|
-
raise CacheTimeout if current == timeout
|
52
|
-
sleep 0.1
|
53
|
-
current = current + 1
|
54
|
-
end
|
42
|
+
fast.join(1)
|
43
|
+
slow.join(1)
|
44
|
+
(fast.status == false && slow.status == false)
|
55
45
|
end
|
56
46
|
alias :remove :delete
|
57
47
|
|
@@ -59,14 +49,9 @@ class Duality
|
|
59
49
|
def flush
|
60
50
|
fast = Thread.new { @fast.flush }
|
61
51
|
slow = Thread.new { @slow.flush }
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
while (fast.alive? || slow.alive?) do
|
66
|
-
raise CacheTimeout if current == timeout
|
67
|
-
sleep 0.1
|
68
|
-
current = current + 1
|
69
|
-
end
|
52
|
+
fast.join(1)
|
53
|
+
slow.join(1)
|
54
|
+
(fast.status == false && slow.status == false)
|
70
55
|
end
|
71
56
|
alias :clean :flush
|
72
57
|
|