memory

package
v0.9.77 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package memory implements the process-local cache.Store used by every deployment. Shared coordination belongs in PostgreSQL.

Index

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

func (s *Store) Close(_ context.Context) error

Close implements cache.Store. Stops the background janitor; calling Close twice is safe (the underlying channel close is once-guarded).

func (*Store) Delete

func (s *Store) Delete(_ context.Context, key string) error

Delete implements cache.Store.

func (*Store) Get

func (s *Store) Get(_ context.Context, key string) ([]byte, error)

Get implements cache.Store.

func (*Store) RefreshSlot

func (s *Store) RefreshSlot(_ context.Context, key string, ttl time.Duration) error

RefreshSlot implements cache.Store. Plain counters only.

func (*Store) RefreshSlotBurst

func (s *Store) RefreshSlotBurst(_ context.Context, key string, ttl time.Duration) error

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

func (s *Store) ReleaseSlot(_ context.Context, key string) error

ReleaseSlot implements cache.Store. Plain counters only.

func (*Store) ReleaseSlotBurst

func (s *Store) ReleaseSlotBurst(_ context.Context, key string) error

ReleaseSlotBurst implements cache.Store. Burst counters only.

func (*Store) Set

func (s *Store) Set(_ context.Context, key string, value []byte, ttl time.Duration) error

Set implements cache.Store.

func (*Store) TokenBucket

func (s *Store) TokenBucket(_ context.Context, key string, capacity, refillPerSec, cost float64) (bool, time.Duration, error)

TokenBucket implements cache.Store.

Jump to

Keyboard shortcuts

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