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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1e593c4955c29dcdfe11f5ba320aa3d5e3262251
4
- data.tar.gz: bb9a9327fdef6c49cf64acb0565a4ed0163142f8
3
+ metadata.gz: c7ddf0941104add01d27ce485c21bc06fa16728a
4
+ data.tar.gz: 0bc51b918fe540b0fe82ccb5e3b3c69786b89096
5
5
  SHA512:
6
- metadata.gz: a01624d8410630bba00809f990423862107247a81c78a17e207c3d65d54e4cb738414dc9ac13341784cb524926c108ccfb4f6194c6ea0be0e7793ad0e4b4db74
7
- data.tar.gz: a46652a0bf33b7014009b6dceac46a8e37a75b98594a93a0ab40824f751110c260edf49d239630a73d4fdd5f0b73c5579a3cf2f9a42f0f3b3486cae36a22df1d
6
+ metadata.gz: b3445f723dab3e14caa5a81a9dd01af44615caee7dc39275cf3a089535dfbc1043ba35442dc8f42b2a7c2579b2a783a82be9e6fcc6f88dced224a8f279332897
7
+ data.tar.gz: e8a8d6f609bb3a86061b7c2aa0ba49d5799de7e46e6ffc54c04464b4876810e6c27a7eeaa4484e0da528d6761cea481357305e34e95411c7fa743dac14024db1
@@ -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.
@@ -1,3 +1,3 @@
1
1
  module RailsKvsDriver
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -37,6 +37,10 @@ describe RailsKvsDriver::DefinedBaseMethod do
37
37
  }.to change{count}.by(3)
38
38
  end
39
39
 
40
+ it 'call has_key?' do
41
+ expect(@instance.has_key?(:a)).to be_true
42
+ end
43
+
40
44
  it 'call length' do
41
45
  expect(@instance.length).to eq(3)
42
46
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_kvs_driver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - alfa-jpn