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.
Files changed (3) hide show
  1. data/HISTORY.md +5 -2
  2. data/lib/duality.rb +10 -25
  3. metadata +1 -1
data/HISTORY.md CHANGED
@@ -1,6 +1,9 @@
1
1
  # Duality
2
2
 
3
- ## pre-release
3
+ ## v0.0.2
4
+
5
+ * moved from process forking to threading model
6
+ * added delete and flush support - async
7
+ * added aliases for cachely
4
8
 
5
- * initial commit
6
9
 
data/lib/duality.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'timeout'
2
2
  class Duality
3
3
 
4
- VERSION = "0.0.2"
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
- timeout = 10 # iterations, or 1 seconds
34
- current = 0
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
- timeout = 10 # iterations, or 1 seconds
49
- current = 0
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
- timeout = 10 # iterations, or 1 seconds
64
- current = 0
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: duality
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: