Documentation ¶
Index ¶
- Variables
- func Get[RESULT any](cache *Cache, key string, validate func(RESULT) error) (item RESULT, err error)
- func NoValidation[T any](T) error
- func Use[T any](cache *Cache, key string, get func() (T, error), validate func(T) error, ...) (result T, err error)
- func UseWithExpInGet[T any](cache *Cache, key string, get func() (T, time.Duration, error), ...) (result T, err error)
- type Cache
- type CacheImpl
- type Config
- type Signal
- type ToKey
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNotFound = cacheerrors.ErrNotFound
Functions ¶
func Get ¶
func Get[RESULT any](cache *Cache, key string, validate func(RESULT) error) (item RESULT, err error)
Get has to be a generic function because else we would lose the type information on l2 cache promotion to l2
func NoValidation ¶
Types ¶
type CacheImpl ¶
type CacheImpl = interfaces.CacheImpl
type Config ¶
type Config struct { L1 CacheImpl //optional, defaults to localcache.Cache (or L1Provider if provided) with 60s cache duration and 1s cleanup interval L1Provider func() (CacheImpl, error) //optional, may be used to create L1 L2 CacheImpl //optional L2Provider func() (CacheImpl, error) //optional, may be used to create L2 Fallback *fallback.Fallback //optional, only used in Use() and UseWithExpInGet() as a fallback to the get parameter FallbackProvider func() (*fallback.Fallback, error) Debug bool ReadCacheHook func(duration time.Duration) //optional CacheMissHook func() //optional CacheInvalidationSignalHooks map[Signal]ToKey CacheInvalidationSignalBroker *signal.Broker //optional, defaults to signal.DefaultBroker if CacheInvalidationSignalHooks is used }
Click to show internal directories.
Click to hide internal directories.