result

package
v3.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsConflictErr

func IsConflictErr(err error) bool

IsConflictErr returns whether error is due to key conflict.

Types

type Cache

type Cache[Value any] struct {
	// contains filtered or unexported fields
}

Cache ...

func New

func New[Value any](lookups []string, copy func(Value) Value) *Cache[Value]

New ...

func NewSized

func NewSized[Value any](lookups []string, copy func(Value) Value, sz int) *Cache[Value]

NewSized ...

func (*Cache[Value]) Clear

func (cache *Cache[Value]) Clear()

Clear empties the cache, calling the invalidate callback.

func (*Cache[Value]) Has

func (c *Cache[Value]) Has(lookup string, keyParts ...any) bool

Has ...

func (*Cache[Value]) Invalidate

func (c *Cache[Value]) Invalidate(lookup string, keyParts ...any)

Invalidate ...

func (*Cache[Value]) Load

func (c *Cache[Value]) Load(lookup string, load func() (Value, error), keyParts ...any) (Value, error)

Load ...

func (*Cache[Value]) SetEvictionCallback

func (c *Cache[Value]) SetEvictionCallback(hook func(Value))

SetEvictionCallback sets the eviction callback to the provided hook.

func (*Cache[Value]) SetInvalidateCallback

func (c *Cache[Value]) SetInvalidateCallback(hook func(Value))

SetInvalidateCallback sets the invalidate callback to the provided hook.

func (*Cache[Value]) SetTTL

func (c *Cache[Value]) SetTTL(ttl time.Duration, update bool)

SetTTL sets the cache item TTL. Update can be specified to force updates of existing items in the cache, this will simply add the change in TTL to their current expiry time.

func (*Cache[Value]) Start

func (c *Cache[Value]) Start(freq time.Duration) bool

Start will start the cache background eviction routine with given sweep frequency. If already running or a freq <= 0 provided, this is a no-op. This will block until eviction routine started.

func (*Cache[Value]) Stop

func (c *Cache[Value]) Stop() bool

Stop will stop cache background eviction routine. If not running this is a no-op. This will block until the eviction routine has stopped.

func (*Cache[Value]) Store

func (c *Cache[Value]) Store(value Value, store func() error) error

Store ...

type ConflictError

type ConflictError struct {
	Key string
}

ConflictError is returned on cache key conflict.

func (ConflictError) Error

func (c ConflictError) Error() string

Error returns the message for this key conflict error.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL