rails_kvs_driver 0.1.0 → 0.1.1
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.rb +4 -4
- data/lib/rails_kvs_driver/defined_base_method.rb +8 -0
- data/lib/rails_kvs_driver/sorted_set.rb +8 -0
- data/lib/rails_kvs_driver/version.rb +1 -1
- data/spec/rails_kvs_driver/defined_base_method_spec.rb +4 -0
- data/spec/rails_kvs_driver/sorted_set_spec.rb +4 -0
- 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: c7ddf0941104add01d27ce485c21bc06fa16728a
|
4
|
+
data.tar.gz: 0bc51b918fe540b0fe82ccb5e3b3c69786b89096
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3445f723dab3e14caa5a81a9dd01af44615caee7dc39275cf3a089535dfbc1043ba35442dc8f42b2a7c2579b2a783a82be9e6fcc6f88dced224a8f279332897
|
7
|
+
data.tar.gz: e8a8d6f609bb3a86061b7c2aa0ba49d5799de7e46e6ffc54c04464b4876810e6c27a7eeaa4484e0da528d6761cea481357305e34e95411c7fa743dac14024db1
|
data/lib/rails_kvs_driver.rb
CHANGED
@@ -36,8 +36,8 @@ module RailsKvsDriver
|
|
36
36
|
|
37
37
|
# get string value from kvs.
|
38
38
|
# @param key [String] key.
|
39
|
-
# @return [String] value
|
40
|
-
# @abstract get value from kvs.
|
39
|
+
# @return [String] value. when doesn't exist, nil
|
40
|
+
# @abstract get value from kvs. when doesn't exist, nil
|
41
41
|
def [](key)
|
42
42
|
raise NoMethodError
|
43
43
|
end
|
@@ -101,8 +101,8 @@ module RailsKvsDriver
|
|
101
101
|
# @param start [Integer] start index
|
102
102
|
# @param stop [Integer] stop index
|
103
103
|
# @param reverse [Boolean] order by desc.
|
104
|
-
# @return [Array<String, Float>>] array of the member and score.
|
105
|
-
# @abstract get array of sorted set.
|
104
|
+
# @return [Array<String, Float>>] array of the member and score. when doesn't exist, nil.
|
105
|
+
# @abstract get array of sorted set. when doesn't exist, nil.
|
106
106
|
def get_sorted_set(key, start=0, stop=-1, reverse=false)
|
107
107
|
raise NoMethodError
|
108
108
|
end
|
@@ -21,6 +21,14 @@ module RailsKvsDriver
|
|
21
21
|
keys.each {|key| yield key, self[key] }
|
22
22
|
end
|
23
23
|
|
24
|
+
# check key in redis.
|
25
|
+
#
|
26
|
+
# @param key [String] key name
|
27
|
+
# @return [Boolean] result
|
28
|
+
def has_key?(key)
|
29
|
+
!(self[key].nil?)
|
30
|
+
end
|
31
|
+
|
24
32
|
# get length of keys.
|
25
33
|
def length
|
26
34
|
keys.length
|
@@ -63,6 +63,14 @@ module RailsKvsDriver
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
+
# check key in sorted set
|
67
|
+
#
|
68
|
+
# @param key [String] key name
|
69
|
+
# @return [Boolean] result
|
70
|
+
def has_key?(key)
|
71
|
+
!(self[key].nil?)
|
72
|
+
end
|
73
|
+
|
66
74
|
# increment member's score of sorted set.
|
67
75
|
#
|
68
76
|
# @param key [String] key of sorted set.
|
@@ -56,6 +56,10 @@ describe RailsKvsDriver::SortedSet do
|
|
56
56
|
expect(@driver.sorted_sets.keys.length).to eq(3)
|
57
57
|
end
|
58
58
|
|
59
|
+
it 'call has_key?' do
|
60
|
+
expect(@driver.sorted_sets.has_key?(:a)).to be_true
|
61
|
+
end
|
62
|
+
|
59
63
|
it 'call length' do
|
60
64
|
expect(@driver.sorted_sets.length).to eq(3)
|
61
65
|
end
|