instance method
write
Ruby on Rails 2.2.3
Since v2.2.3Signature
write(key, value, options = nil)
Writes a value to the cache.
Possible options:
-
:unless_exist- set to true if you don’t want to update the cache if the key is already set. -
:expires_in- the number of seconds that this value may stay in the cache. See ActiveSupport::Cache::Store#write for an example.
Parameters
-
keyreq -
valuereq -
optionsopt = nil
Source
# File activesupport/lib/active_support/cache/mem_cache_store.rb, line 58
def write(key, value, options = nil)
super
method = options && options[:unless_exist] ? :add : :set
# memcache-client will break the connection if you send it an integer
# in raw mode, so we convert it to a string to be sure it continues working.
value = value.to_s if raw?(options)
response = @data.send(method, key, value, expires_in(options), raw?(options))
response == Response::STORED
rescue MemCache::MemCacheError => e
logger.error("MemCacheError (#{e}): #{e.message}")
false
end
Defined in activesupport/lib/active_support/cache/mem_cache_store.rb line 58
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::Cache::MemCacheStore