Cache is an interface to an expiring cache. It behaves (and is modeled) like the Memcached interface. It is keyed by strings (250 bytes at most).

Many callers will make exclusive use of Set and Get, but more exotic functions are also available.


Here is a typical Get/Set interaction:

var items []*Item
if err := cache.Get("items", &items); err != nil {
  items = loadItems()
  go cache.Set("items", items, cache.DEFAULT)

Note that the caller will frequently not wait for Set() to complete.


It is assumed that callers will infrequently check returned errors, since any request should be fulfillable without finding anything in the cache. As a result, all errors other than ErrCacheMiss and ErrNotStored will be logged to revel.ERROR, so that the developer does not need to check the return value to discover things like deserialization or connection errors.

Cache is referenced in 0 repositories