Documentation ¶
Overview ¶
ProxyCache - universal cache filling algorithm
Idea ¶
Instead of trying to making cache lookups and determining if you should perform some expensive calculation, you pass calculation fetcher as a delegate into ProxyCache which will figure out caching state by itself and use fetcher if necessary.
Parameters ¶
Algorithm considers various parameters that might affect caching behavior: item expiration, ttl (specified per-request), request timeout, throttle time between fetcher calls, results of validation (preformed by validator func).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ProxyCache ¶
func ProxyCache(key string, target interface{}, fetcher Fetcher, spec *ResourceSpec) error
Types ¶
type RedisPCache ¶
Redis-flavor of ProxyCache, that uses redis for both Store and Locker backends
func RedisPCacheNew ¶
func RedisPCacheNew(prefix, network, addr string) RedisPCache
type ResourceSpec ¶
type Store ¶
type Store interface { Get(string, interface{}) (bool, *time.Time, *time.Time) // (key, target) -> (retrieved, creation_time, last_fetch_time) Set(string, interface{}, time.Duration) error // (key, item, expire) -> error }
Storage backend is assumed to implement some kind of cache replacement algorithm