Documentation
¶
Overview ¶
Package memory provides an in-process [cache.Backend]: zero infrastructure, used for dev/CI and for per-instance frame storage in the retry endpoint. It offers no cross-instance coordination — SetNX races are resolved only within this process.
Index ¶
- type Backend
- func (b *Backend) Close() error
- func (b *Backend) Del(_ context.Context, key []byte) error
- func (b *Backend) Get(_ context.Context, key []byte) ([]byte, error)
- func (b *Backend) Healthy(_ context.Context) bool
- func (b *Backend) Len() int
- func (b *Backend) Set(_ context.Context, key, val []byte, ttl time.Duration) error
- func (b *Backend) SetNX(_ context.Context, key, val []byte, ttl time.Duration) (bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
Backend is a striped in-memory cache. The keyspace is sharded across independently-locked maps so concurrent workers do not serialise on a single mutex.
func New ¶
New constructs an in-memory backend with the given soft key cap (0 = unbounded). The cap is enforced per shard (maxKeys/shardCount) with simple oldest-wins eviction, which is sufficient for the bounded TTL workloads here.
func (*Backend) Len ¶
Len reports the current entry count across all shards (including expired entries not yet swept). Used by the retry endpoint's cache-size sampler.