spymemcached.jruby 1.0.6-java → 1.0.7-java

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: 851aefc720e9fdaab213529acb1fd7adae37cd3d
4
- data.tar.gz: 7632fb094f798fa09ee6fd9faeb6dc7df75731be
3
+ metadata.gz: 1193b806e0f10e5614d045d8caff971a0f3c1f40
4
+ data.tar.gz: d3815486843195c3283c5edeacbb6d2c97d5190a
5
5
  SHA512:
6
- metadata.gz: 3d6583f571dc48a54ef0da6fca9bdae3258d95d8a01cf20f5fb6cd9891805f196845595c145aa7b0402aaa295cd9a816acde0e09c6a6c29e1c5339c05a8629e3
7
- data.tar.gz: 64b8a8edd19cd0d801471f87887c714753cc8d6f93de219c9000882562a3af1fc498c7449093283257d786805c85a449063b4934badac25b0d5e940b82c57658
6
+ metadata.gz: feebac09805bf08357710cf7ff2916e991dc18c64124682a152ae486a563dde48fa7dd247d2c5c0f50a6c9278c23d782eee2b20eb2fdab25697f40761d3f401f
7
+ data.tar.gz: 87626fa88fc1818dd523f4515fa49bf887267e97d59264b24049fca0e157190b021375491f22e6febe4f024180eb1a9a290f6fbc7a8b6123edce99f98846080f
data/lib/spymemcached.rb CHANGED
@@ -81,12 +81,12 @@ class Spymemcached
81
81
  @client.delete(encode(key))
82
82
  end
83
83
 
84
- def incr(key, by=1)
85
- @client.incr(encode(key), by)
84
+ def incr(key, by=1, ttl=0, default=0)
85
+ @client.incr(encode(key), by, ttl, default)
86
86
  end
87
87
 
88
- def decr(key, by=1)
89
- @client.decr(encode(key), by)
88
+ def decr(key, by=1, ttl=0, default=0)
89
+ @client.decr(encode(key), by, ttl, default)
90
90
  end
91
91
 
92
92
  def append(key, value)
@@ -34,12 +34,12 @@ class Spymemcached
34
34
  op(:delete, key) ? Response::DELETED : Response::NOT_FOUND
35
35
  end
36
36
 
37
- def incr(key, by=1, *args)
38
- op(:incr, key, by)
37
+ def incr(key, by=1, ttl=0)
38
+ op(:incr, key, by, ttl)
39
39
  end
40
40
 
41
- def decr(key, by=1, *args)
42
- op(:decr, key, by)
41
+ def decr(key, by=1, ttl=0)
42
+ op(:decr, key, by, ttl)
43
43
  end
44
44
 
45
45
  def flush_all
Binary file
@@ -58,6 +58,12 @@ class SpymemcachedBinaryProtocolTest < Test::Unit::TestCase
58
58
 
59
59
  @client.cas('key') { '7' }
60
60
  assert_equal 8, @client.incr('key')
61
+
62
+ assert_equal 100, @client.incr('incr_key', 1, 0, 100)
63
+ assert_equal 100, @client.decr('decr_key', 1, 0, 100)
64
+
65
+ assert_equal 101, @client.incr('incr_key', 1, 0, 100)
66
+ assert_equal 99, @client.decr('decr_key', 1, 0, 100)
61
67
  end
62
68
 
63
69
  def test_fetch
@@ -58,6 +58,12 @@ class SpymemcachedPlainProtocolTest < Test::Unit::TestCase
58
58
 
59
59
  @client.cas('key') { '7' }
60
60
  assert_equal 8, @client.incr('key')
61
+
62
+ assert_equal 100, @client.incr('incr_key', 1, 0, 100)
63
+ assert_equal 100, @client.decr('decr_key', 1, 0, 100)
64
+
65
+ assert_equal 101, @client.incr('incr_key', 1, 0, 100)
66
+ assert_equal 99, @client.decr('decr_key', 1, 0, 100)
61
67
  end
62
68
 
63
69
  def test_fetch
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
 
4
4
  class SpymemcachedTest < Test::Unit::TestCase
5
5
  def setup
6
- @client = binary_client
6
+ @client = plain_client
7
7
  @client.flush_all
8
8
  end
9
9
 
@@ -29,6 +29,9 @@ class SpymemcachedTest < Test::Unit::TestCase
29
29
 
30
30
  @client.add('touch_key1', 'v1', 2)
31
31
 
32
+ assert_equal 0, @client.incr('incr_key', 1, 1)
33
+ assert_equal 0, @client.decr('decr_key', 1, 1)
34
+
32
35
  sleep 0.1
33
36
 
34
37
  assert_equal 'v2', @client.get('add_key2')
@@ -56,6 +59,9 @@ class SpymemcachedTest < Test::Unit::TestCase
56
59
 
57
60
  assert_equal 'v1', @client.get('replace_key1')
58
61
  assert_nil @client.get('replace_key2')
62
+
63
+ assert_nil @client.get('incr_key')
64
+ assert_nil @client.get('decr_key')
59
65
  end
60
66
 
61
67
  def test_timeout
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spymemcached.jruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  platform: java
6
6
  authors:
7
7
  - Xiao Li