Documentation
¶
Index ¶
- Variables
- func DiskCapacityBytes(dir string) (int64, error)
- type Cache
- func NewDisk(dir string, maxBytes int64, warn func(error)) (*Cache[[]byte], error)
- func NewDiskAny(dir string, maxBytes int64, warn func(error)) (*Cache[any], error)
- func NewMem(maxEntries int, maxBytes int64) *Cache[[]byte]
- func NewMemFunc[V any](maxEntries int, maxBytes int64, weigh func(V) int64) *Cache[V]
- func (c *Cache[V]) Dir() string
- func (c *Cache[V]) Get(ctx context.Context, key string, load LoadFunc[V]) (V, func(), error)
- func (c *Cache[V]) Invalidate(key string)
- func (c *Cache[V]) IsNegative(key string) bool
- func (c *Cache[V]) SetLimits(maxEntries int, maxBytes int64)
- func (c *Cache[V]) SetWarn(warn func(error))
- func (c *Cache[V]) Stats() Stats
- type LoadFunc
- type Stats
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInvalidName = errors.New("twcache: cache name escapes the cache directory")
Functions ¶
func DiskCapacityBytes ¶
Types ¶
type Cache ¶
type Cache[V any] struct { NotFound func(error) bool Validate func(V) bool // contains filtered or unexported fields }
func NewDiskAny ¶ added in v1.8.8
func NewMemFunc ¶ added in v1.8.8
func (*Cache[V]) Invalidate ¶ added in v1.8.1
func (*Cache[V]) IsNegative ¶ added in v1.8.1
Click to show internal directories.
Click to hide internal directories.