memcached 1.6.0 → 1.6.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -486,7 +486,7 @@ Please note that when <tt>:no_block => true</tt>, update methods do not raise on
486
486
 
487
487
  # Gets a key's value from the server. Accepts a String <tt>key</tt> or array of String <tt>keys</tt>.
488
488
  #
489
- # Also accepts a <tt>encode</tt> value, which defaults to <tt>true</tt>. Set <tt>encode</tt> to <tt>false</tt> if you want the <tt>value</tt> to be returned directly as a String. Otherwise it will be assumed to be an encoded Ruby object and decoded.
489
+ # Also accepts a <tt>decode</tt> value, which defaults to <tt>true</tt>. Set <tt>decode</tt> to <tt>false</tt> if you want the <tt>value</tt> to be returned directly as a String. Otherwise it will be assumed to be an encoded Ruby object and decoded.
490
490
  #
491
491
  # If you pass a String key, and the key does not exist on the server, <b>Memcached::NotFound</b> will be raised. If you pass an array of keys, memcached's <tt>multiget</tt> mode will be used, and a hash of key/value pairs will be returned. The hash will contain only the keys that were found.
492
492
  #
@@ -494,7 +494,7 @@ Please note that when <tt>:no_block => true</tt>, update methods do not raise on
494
494
  #
495
495
  # Note that when you rescue Memcached::NotFound exceptions, you should use a the block rescue syntax instead of the inline syntax. Block rescues are very fast, but inline rescues are very slow.
496
496
  #
497
- def get(keys, encode=true)
497
+ def get(keys, decode=true)
498
498
  if keys.is_a? Array
499
499
  # Multi get
500
500
  ret = Lib.memcached_mget(@struct, keys);
@@ -504,13 +504,13 @@ Please note that when <tt>:no_block => true</tt>, update methods do not raise on
504
504
  value, key, flags, ret = Lib.memcached_fetch_rvalue(@struct)
505
505
  while ret != 21 do # Lib::MEMCACHED_END
506
506
  if ret == 0 # Lib::MEMCACHED_SUCCESS
507
- hash[key] = encode ? [value, flags] : value
507
+ hash[key] = decode ? [value, flags] : value
508
508
  elsif ret != 16 # Lib::MEMCACHED_NOTFOUND
509
509
  check_return_code(ret, key)
510
510
  end
511
511
  value, key, flags, ret = Lib.memcached_fetch_rvalue(@struct)
512
512
  end
513
- if encode
513
+ if decode
514
514
  hash.each do |key, value_and_flags|
515
515
  hash[key] = @codec.decode(key, *value_and_flags)
516
516
  end
@@ -520,7 +520,7 @@ Please note that when <tt>:no_block => true</tt>, update methods do not raise on
520
520
  # Single get
521
521
  value, flags, ret = Lib.memcached_get_rvalue(@struct, keys)
522
522
  check_return_code(ret, keys)
523
- encode ? @codec.decode(keys, value, flags) : value
523
+ decode ? @codec.decode(keys, value, flags) : value
524
524
  end
525
525
  rescue => e
526
526
  tries ||= 0
@@ -539,11 +539,11 @@ Please note that when <tt>:no_block => true</tt>, update methods do not raise on
539
539
  end
540
540
 
541
541
  # Gets a key's value from the previous server. Only useful with random distribution.
542
- def get_from_last(key, encode=true)
542
+ def get_from_last(key, decode=true)
543
543
  raise ArgumentError, "get_from_last() is not useful unless :random distribution is enabled." unless options[:distribution] == :random
544
544
  value, flags, ret = Lib.memcached_get_from_last_rvalue(@struct, key)
545
545
  check_return_code(ret, key)
546
- encode ? @codec.decode(key, value, flags) : value
546
+ decode ? @codec.decode(key, value, flags) : value
547
547
  end
548
548
 
549
549
  ### Information methods
@@ -2,12 +2,12 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "memcached"
5
- s.version = "1.6.0"
5
+ s.version = "1.6.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Evan Weaver"]
9
9
  s.cert_chain = ["/Users/eweaver/cloudburst/configuration/gem_certificates/evan_weaver-original-public_cert.pem"]
10
- s.date = "2013-06-10"
10
+ s.date = "2013-06-11"
11
11
  s.description = "An interface to the libmemcached C client."
12
12
  s.email = ""
13
13
  s.extensions = ["ext/extconf.rb"]
@@ -1,6 +1,12 @@
1
1
 
2
2
  require File.expand_path("#{File.dirname(__FILE__)}/../test_helper")
3
3
 
4
+ class NilClass
5
+ def to_str
6
+ "nil"
7
+ end
8
+ end
9
+
4
10
  class MemcachedTest < Test::Unit::TestCase
5
11
 
6
12
  def setup
@@ -265,6 +271,15 @@ class MemcachedTest < Test::Unit::TestCase
265
271
  end
266
272
  end
267
273
 
274
+ def test_get_coerces_string_type
275
+ assert_raises(Memcached::NotFound) do
276
+ @cache.get nil
277
+ end
278
+ assert_raises(TypeError) do
279
+ @cache.get 1
280
+ end
281
+ end
282
+
268
283
  def test_get_with_server_timeout
269
284
  socket = stub_server 43047
270
285
  cache = Memcached.new("localhost:43047:1", :timeout => 0.5, :exception_retry_limit => 0)
@@ -408,9 +423,12 @@ class MemcachedTest < Test::Unit::TestCase
408
423
  @cache.get(["#{key}_1"], false))
409
424
  end
410
425
 
411
- def test_get_multi_checks_types
412
- assert_raises(TypeError, ArgumentError) do
413
- @cache.get([nil])
426
+ def test_get_multi_coerces_string_type
427
+ assert_nothing_raised do
428
+ @cache.get [nil]
429
+ end
430
+ assert_raises(TypeError) do
431
+ @cache.get [1]
414
432
  end
415
433
  end
416
434
 
@@ -522,6 +540,16 @@ class MemcachedTest < Test::Unit::TestCase
522
540
  end
523
541
  end
524
542
 
543
+ def test_set_coerces_string_type
544
+ assert_nothing_raised do
545
+ @cache.set nil, @value
546
+ end
547
+
548
+ assert_raises(TypeError) do
549
+ @cache.set 1, @value
550
+ end
551
+ end
552
+
525
553
  def disabled_test_set_retry_on_client_error
526
554
  # FIXME Test passes, but Mocha doesn't restore the original method properly
527
555
  Rlibmemcached.stubs(:memcached_set).raises(Memcached::ClientError)
@@ -1342,4 +1370,3 @@ class MemcachedTest < Test::Unit::TestCase
1342
1370
  end
1343
1371
 
1344
1372
  end
1345
-
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: memcached
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.6.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -36,7 +36,7 @@ cert_chain:
36
36
  QUMzSFJXWnhJUzFzZm4vU3NxYTdFN29RTWt2NUZBWHIKeDVyS2VQZlhJTmY4
37
37
  WFRKY3prbDlPQkVZZEU5YU5kSnNKcFhEMGFzTGdHVndCSUNTNUJqb2hwNm1p
38
38
  ekpjREMxKwp5WjA9Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K
39
- date: 2013-06-10 00:00:00.000000000 Z
39
+ date: 2013-06-11 00:00:00.000000000 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
metadata.gz.sig CHANGED
Binary file