зеркало из https://github.com/github/memcached.git
Merge remote-tracking branch 'origin/memcached-rails-fix-write-with-nil-options' into memcached-rails-updates
This commit is contained in:
Коммит
79e4eb2f32
|
@ -100,13 +100,14 @@ class Memcached
|
|||
|
||||
# Alternative to #set. Accepts a key, value, and an optional options hash supporting the
|
||||
# options :raw and :ttl.
|
||||
def write(key, value, options = {})
|
||||
def write(key, value, options = nil)
|
||||
value = value.to_s if options && options[:raw]
|
||||
ttl = options[:ttl] || options[:expires_in] || @default_ttl
|
||||
ttl = options ? (options[:ttl] || options[:expires_in] || @default_ttl) : @default_ttl
|
||||
raw = options ? options[:raw] : nil
|
||||
if options && options[:unless_exist]
|
||||
add(key, value, ttl, options[:raw])
|
||||
add(key, value, ttl, raw)
|
||||
else
|
||||
set(key, value, ttl, options[:raw])
|
||||
set(key, value, ttl, raw)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -312,6 +312,11 @@ class RailsTest < Test::Unit::TestCase
|
|||
assert_equal @value, @cache.read(key, nil)
|
||||
end
|
||||
|
||||
def test_write_with_nil_options
|
||||
@cache.write key, @value, nil
|
||||
assert_equal @value, @cache.read(key)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def key
|
||||
|
|
Загрузка…
Ссылка в новой задаче