redis-deque 0.1.0 → 0.2.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/lib/redis/deque.rb +12 -4
- data/spec/redis_deque_spec.rb +28 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1a41c2cb5cb29d32dc7e30a396689e1e6015003eeba9c1505ecfc1f61a248d3
|
4
|
+
data.tar.gz: a0c3cce5a779ee790fdcd64eeecb5129022a2898bd5e9f95903e7a0612fe4af2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d7ecca6d10e343c10d3d57e4aedaeaa289b380ba27169d15523f0c22c0279ead1b0bbcf4cb21a628a742123709b21ffb486cc3079f9130dd6b3463b76b64dfb
|
7
|
+
data.tar.gz: 2423e22c76e865cab81d888bd71760a12dbf74fce9828d21e1df6b2da09325b45bd6c0a1d4bb18b0a953217750853af4618a0bb56c973788137b4c77eb3480e0
|
data/CHANGELOG.md
ADDED
data/lib/redis/deque.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
class Redis
|
4
4
|
class Deque
|
5
|
-
VERSION = '0.
|
5
|
+
VERSION = '0.2.0'
|
6
6
|
|
7
7
|
def self.version
|
8
8
|
"redis-deque version #{VERSION}"
|
@@ -50,8 +50,16 @@ class Redis
|
|
50
50
|
@last_message
|
51
51
|
end
|
52
52
|
|
53
|
-
def commit
|
54
|
-
@redis.lrem(@process_queue_name, 0,
|
53
|
+
def commit(message)
|
54
|
+
@redis.lrem(@process_queue_name, 0, message)
|
55
|
+
end
|
56
|
+
|
57
|
+
def commit_last
|
58
|
+
commit @last_message
|
59
|
+
end
|
60
|
+
|
61
|
+
def commit_all
|
62
|
+
@redis.del @process_queue_name
|
55
63
|
end
|
56
64
|
|
57
65
|
def process(non_block = false, timeout = nil)
|
@@ -59,7 +67,7 @@ class Redis
|
|
59
67
|
loop do
|
60
68
|
message = pop(non_block)
|
61
69
|
ret = yield message if block_given?
|
62
|
-
|
70
|
+
commit_last if ret
|
63
71
|
break if message.nil? || (non_block && empty?)
|
64
72
|
end
|
65
73
|
end
|
data/spec/redis_deque_spec.rb
CHANGED
@@ -62,12 +62,38 @@ describe Redis::Deque do
|
|
62
62
|
message.should be == 'a'
|
63
63
|
end
|
64
64
|
|
65
|
-
it 'should remove the element from bp_queue if
|
65
|
+
it 'should remove the last element from bp_queue if commit_last is called' do
|
66
66
|
@queue << 'a'
|
67
|
+
@queue << 'b'
|
68
|
+
@queue.pop true
|
69
|
+
@queue.pop true
|
70
|
+
|
71
|
+
@redis.llen('bp__test').should be == 2
|
72
|
+
@queue.commit_last
|
73
|
+
@redis.llen('bp__test').should be == 1
|
74
|
+
@redis.lpop('bp__test').should be == 'a'
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'should remove specific element from bp_queue if commit is called' do
|
78
|
+
@queue << 'a'
|
79
|
+
@queue << 'b'
|
80
|
+
@queue.pop true
|
67
81
|
@queue.pop true
|
68
82
|
|
83
|
+
@redis.llen('bp__test').should be == 2
|
84
|
+
@queue.commit 'a'
|
69
85
|
@redis.llen('bp__test').should be == 1
|
70
|
-
@
|
86
|
+
@redis.lpop('bp__test').should be == 'b'
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'should remove everything from bp_queue if commit_all is called' do
|
90
|
+
@queue << 'a'
|
91
|
+
@queue << 'b'
|
92
|
+
@queue.pop true
|
93
|
+
@queue.pop true
|
94
|
+
|
95
|
+
@redis.llen('bp__test').should be == 2
|
96
|
+
@queue.commit_all
|
71
97
|
@redis.llen('bp__test').should be == 0
|
72
98
|
end
|
73
99
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis-deque
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jaakko Rinta-Filppula
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-02-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: redis
|
@@ -63,6 +63,7 @@ extensions: []
|
|
63
63
|
extra_rdoc_files: []
|
64
64
|
files:
|
65
65
|
- ".gitignore"
|
66
|
+
- CHANGELOG.md
|
66
67
|
- Gemfile
|
67
68
|
- LICENSE.txt
|
68
69
|
- README.md
|