Documentation ¶
Overview ¶
Package cache defines the ResourceCache interface and provides the most basic implementation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ResourceCache ¶
type ResourceCache interface { // Lookup returns a Resource matching req. It returns nil (with no error) // when ResourceCache contains no matching Resource. Lookup(req *http.Request) (*resource.Resource, error) // Store stores the provided Resource r into the cache. Store(r *resource.Resource) error }
ResourceCache caches resource.Resources.
ResourceCache implementations should match Resources in a way analogous to HTTP caches: the returned Resource should have a matching RequestURL and, if applicable, compatible HTTP Variants headers (but see Bugs with OnMemoryCache).
For HTTP Variants, please see: https://httpwg.org/http-extensions/draft-ietf-httpbis-variants.html.
func NewBoundedInMemoryCache ¶
func NewBoundedInMemoryCache(size int) ResourceCache
NewBoundedInMemoryCache returns a new ResourceCache that stores Resources in memory, with an eviction policy after `size` entries. size must be positive.
func NewOnMemoryCache ¶
func NewOnMemoryCache() ResourceCache
NewOnMemoryCache creates and initializes a new ResourceCache storing Resources on memory.
func NilCache ¶
func NilCache() ResourceCache
NilCache returns a ResourceCache that stores and retrieves nothing.
Notes ¶
Bugs ¶
OnMemoryCache uses only RequestURL for the cache key at this moment; it is not aware of Vary or Variants yet.