Method: ActiveSupport::Cache::Store#write
- Defined in:
- lib/active_support/cache.rb
#write(key, value, options = nil) ⇒ Object
Writes the given value to the cache, with the given key.
You may also specify additional options via the options argument. The specific cache store implementation will decide what to do with options.
For example, MemCacheStore supports the :expires_in option, which tells the memcached server to automatically expire the cache item after a certain period:
cache = ActiveSupport::Cache::MemCacheStore.new
cache.write("foo", "bar", :expires_in => 5.seconds)
cache.read("foo") # => "bar"
sleep(6)
cache.read("foo") # => nil
177 178 179 |
# File 'lib/active_support/cache.rb', line 177 def write(key, value, = nil) log("write", key, ) end |