write(key, value, options = nil) public

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"
  cache.read("foo")  # => nil
Show source
Register or log in to add new notes.