Documentation
¶
Overview ¶
Package memory provides an in-process cache.Cache for tests and local development. It is not shared between instances: do not use it as a distributed cache in production.
Values are JSON encoded on Set and decoded on Get, mimicking the serialization boundary of network caches and preventing aliasing bugs.
Index ¶
- Variables
- type Cache
- func (c *Cache) Delete(ctx context.Context, key string) error
- func (c *Cache) Get(ctx context.Context, key string, value any) error
- func (c *Cache) Increment(ctx context.Context, key string, delta int64, ttl time.Duration) (int64, error)
- func (c *Cache) Len() int
- func (c *Cache) Set(ctx context.Context, key string, value any, ttl time.Duration) error
- type Option
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInvalidTTL = errors.New("cache/memory: ttl must be positive")
ErrInvalidTTL is returned when an entry is written without a positive TTL.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is an in-memory cache with lazy expiration.
Click to show internal directories.
Click to hide internal directories.