rails_kvs_driver 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rails_kvs_driver/sorted_set.rb +18 -1
- data/lib/rails_kvs_driver/version.rb +1 -1
- data/spec/rails_kvs_driver/sorted_set_spec.rb +10 -1
- 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: 4f78813ebc99ba319770bd8ef0c4fbdc09514cd4
|
4
|
+
data.tar.gz: b59f2e73ab356e50cb73f455582c9765d3951684
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be8643028faa6de55130899e3e45c267db0eab94a3af8e2be727cc531a204856aca4b4ad9adc824d0e568a4f9e08fd274078ece81529ed76170f32bb2669067c
|
7
|
+
data.tar.gz: 260084bd150f5ebb1452e6be392543694c7832a62fa3f8ae7c0cc2c63b0e981c8fd17242d8ab8a2b58ec23af85f1d25e1b27b5c53924aed5776bb0cb66d99f66
|
@@ -34,7 +34,16 @@ module RailsKvsDriver
|
|
34
34
|
return member_set
|
35
35
|
end
|
36
36
|
|
37
|
+
# count member of sorted_set
|
38
|
+
#
|
39
|
+
# @param key [String] sorted_set key
|
40
|
+
def count(key)
|
41
|
+
@driver_instance.count_sorted_set_member(key)
|
42
|
+
end
|
43
|
+
|
37
44
|
# delete key
|
45
|
+
#
|
46
|
+
# @param key [String] sorted_set key
|
38
47
|
def delete(key)
|
39
48
|
@driver_instance.delete(key)
|
40
49
|
end
|
@@ -52,7 +61,7 @@ module RailsKvsDriver
|
|
52
61
|
# @param limit [Integer] limit number to acquire at a time.
|
53
62
|
# @param &block [{|member, score, position| }] each the block of code for each member of sorted set.
|
54
63
|
def each_member(key, reverse=false, limit=1000)
|
55
|
-
member_count =
|
64
|
+
member_count = count(key)
|
56
65
|
member_position = 0
|
57
66
|
|
58
67
|
while member_position < member_count
|
@@ -92,5 +101,13 @@ module RailsKvsDriver
|
|
92
101
|
def length
|
93
102
|
keys.length
|
94
103
|
end
|
104
|
+
|
105
|
+
# remove member of sorted_set
|
106
|
+
#
|
107
|
+
# @param key [String] sorted_set key
|
108
|
+
# @param member [String] member of sorted_se
|
109
|
+
def remove(key, member)
|
110
|
+
@driver_instance.remove_sorted_set(key, member)
|
111
|
+
end
|
95
112
|
end
|
96
113
|
end
|
@@ -12,7 +12,8 @@ describe RailsKvsDriver::SortedSet do
|
|
12
12
|
get_sorted_set: [[:a,:b],[:c,:d]],
|
13
13
|
get_sorted_set_keys: [:a,:b,:c],
|
14
14
|
get_sorted_set_score: 100,
|
15
|
-
increment_sorted_set: 10
|
15
|
+
increment_sorted_set: 10,
|
16
|
+
remove_sorted_set: true
|
16
17
|
})
|
17
18
|
end
|
18
19
|
|
@@ -25,6 +26,10 @@ describe RailsKvsDriver::SortedSet do
|
|
25
26
|
expect(@driver.sorted_sets['hoge','fuga']).to eq(100)
|
26
27
|
end
|
27
28
|
|
29
|
+
it 'call count' do
|
30
|
+
expect(@driver.sorted_sets.count(:a)).to eq(100)
|
31
|
+
end
|
32
|
+
|
28
33
|
it 'call delete' do
|
29
34
|
expect(@driver.sorted_sets.delete(:a)).to be_true
|
30
35
|
end
|
@@ -63,4 +68,8 @@ describe RailsKvsDriver::SortedSet do
|
|
63
68
|
it 'call length' do
|
64
69
|
expect(@driver.sorted_sets.length).to eq(3)
|
65
70
|
end
|
71
|
+
|
72
|
+
it 'call remove' do
|
73
|
+
expect(@driver.sorted_sets.remove(:a, :b)).to be_true
|
74
|
+
end
|
66
75
|
end
|