Documentation
¶
Overview ¶
Package memory implements the process-local cache.Store used by every deployment. Shared coordination belongs in PostgreSQL.
Index ¶
- type Store
- func (s *Store) AcquireSlot(_ context.Context, key string, limit int64, ttl time.Duration) (bool, int64, error)
- func (s *Store) AcquireSlotBurst(_ context.Context, key string, sustained, ceiling int64, ...) (bool, int64, error)
- func (s *Store) Close(_ context.Context) error
- func (s *Store) Delete(_ context.Context, key string) error
- func (s *Store) Get(_ context.Context, key string) ([]byte, error)
- func (s *Store) RefreshSlot(_ context.Context, key string, ttl time.Duration) error
- func (s *Store) RefreshSlotBurst(_ context.Context, key string, ttl time.Duration) error
- func (s *Store) ReleaseSlot(_ context.Context, key string) error
- func (s *Store) ReleaseSlotBurst(_ context.Context, key string) error
- func (s *Store) Set(_ context.Context, key string, value []byte, ttl time.Duration) error
- func (s *Store) TokenBucket(_ context.Context, key string, capacity, refillPerSec, cost float64) (bool, time.Duration, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a sharded in-memory implementation of cache.Store.
func New ¶
func New() *Store
New returns a fresh in-memory Store with a background janitor that reclaims expired kv entries, stale slots, and idle rate-limit buckets. The janitor exits on Close.
func (*Store) AcquireSlot ¶
func (s *Store) AcquireSlot(_ context.Context, key string, limit int64, ttl time.Duration) (bool, int64, error)
AcquireSlot implements cache.Store.
func (*Store) AcquireSlotBurst ¶
func (s *Store) AcquireSlotBurst(_ context.Context, key string, sustained, ceiling int64, burstBudget, ttl time.Duration) (bool, int64, error)
AcquireSlotBurst implements cache.Store.
func (*Store) Close ¶
Close implements cache.Store. Stops the background janitor; calling Close twice is safe (the underlying channel close is once-guarded).
func (*Store) RefreshSlot ¶
RefreshSlot implements cache.Store. Plain counters only.
func (*Store) RefreshSlotBurst ¶
RefreshSlotBurst implements cache.Store. Extends a live burst slot's idle TTL; a no-op on an absent or already-expired slot so a stray refresh cannot revive a counter the sweep is about to reap.
func (*Store) ReleaseSlot ¶
ReleaseSlot implements cache.Store. Plain counters only.
func (*Store) ReleaseSlotBurst ¶
ReleaseSlotBurst implements cache.Store. Burst counters only.