Documentation ¶
Overview ¶
Package caching implements a Storage wrapper that implements caching on reads, and is backed by another Storage instance. The caching layer is intentionally simple.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cache ¶
type Cache interface { // Put caches the supplied Items into the cache. If an Item already exists in // the cache, it will be overridden. // // If exp, the supplied expiration Duration, is >0, the cache should only // store the data if it can expire it after this period of time. // // This method does not return whether or not the caching storage was // successful. Put(c context.Context, exp time.Duration, items ...*Item) // Get retrieves a cached entry. If the entry was present, a non-nil value // will be returned, even if the data length is zero. If the entry was not // present, nil will be returned. // // This method does not distinguish between an error and missing data. Either // valid data is returned, or it is not. Get(c context.Context, items ...*Item) }
Cache is a simple cache interface. It is capable of storage and retrieval.
type Item ¶
type Item struct { // Schema is the item's schema value. If empty, the item is schemaless. Schema string // Type is the item's type identifier. If empty, the item has no type. Type string // Key is the item's individual key. It uniquely identifies the Item within // the scope of the Schema and Type. Key string // Data is the Item's data. For Put, the contents of this Data will be used to // populate the cache. For Get, this value will be non-nil and populated with // the retrieved data, or nil if the item was not present in the cache. Data []byte }
Item is a single cache item. An item is uniquely identified by its Schema and Key sequence.
Click to show internal directories.
Click to hide internal directories.