sparrow 0.4 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sparrow.rb +1 -1
- data/lib/sparrow/queues/memory.rb +3 -6
- data/lib/sparrow/queues/sqlite.rb +12 -0
- metadata +1 -1
data/lib/sparrow.rb
CHANGED
@@ -37,9 +37,7 @@ module Sparrow
|
|
37
37
|
|
38
38
|
def to_disk!
|
39
39
|
copy = self.queue_data.dup
|
40
|
-
copy
|
41
|
-
self.sqlite.push(value)
|
42
|
-
end
|
40
|
+
self.sqlite.insert(copy)
|
43
41
|
self.queue_data = self.queue_data - copy
|
44
42
|
end
|
45
43
|
|
@@ -49,9 +47,8 @@ module Sparrow
|
|
49
47
|
|
50
48
|
def recover!
|
51
49
|
logger.debug "Recovering queue"
|
52
|
-
|
53
|
-
|
54
|
-
end
|
50
|
+
self.queue_data.concat(self.sqlite.all)
|
51
|
+
self.sqlite.clear!
|
55
52
|
end
|
56
53
|
|
57
54
|
def sqlite
|
@@ -49,6 +49,18 @@ module Sparrow
|
|
49
49
|
db.execute("DELETE FROM queues")
|
50
50
|
end
|
51
51
|
|
52
|
+
def all
|
53
|
+
db.execute("SELECT * FROM queues").collect {|v| v[1] }
|
54
|
+
end
|
55
|
+
|
56
|
+
def insert(values)
|
57
|
+
db.transaction do |d|
|
58
|
+
values.each do |v|
|
59
|
+
db.execute("INSERT INTO queues (data) VALUES (?)", v)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
52
64
|
private
|
53
65
|
|
54
66
|
def db_path
|