Documentation
¶
Index ¶
- Constants
- Variables
- type Config
- type LocalCache
- type MemoryStore
- func (s *MemoryStore) CleanAndCount(ctx context.Context, key string, windowStart int64) error
- func (s *MemoryStore) Close() error
- func (s *MemoryStore) Delete(ctx context.Context, key string) error
- func (s *MemoryStore) Expire(ctx context.Context, key string, expiration time.Duration) error
- func (s *MemoryStore) Get(_ context.Context, key string, value any) error
- func (s *MemoryStore) GetCount(ctx context.Context, key string) (int64, error)
- func (s *MemoryStore) Increment(ctx context.Context, key string, timestamp int64) error
- func (s *MemoryStore) Set(_ context.Context, key string, value any, expiration time.Duration) error
- type Store
Constants ¶
View Source
const ( PrefixSession = "session:" PrefixHealth = "health:" PrefixVersion = "version:" PrefixRate = "rate:" // Cache durations DefaultTTL = 15 * time.Minute HealthTTL = 30 * time.Minute StatsTTL = 5 * time.Minute SessionsTTL = 1 * time.Minute CleanupInterval = 1 * time.Minute // Increased to reduce cleanup frequency )
Variables ¶
View Source
var ( ErrKeyNotFound = errors.New("cache: key not found") ErrClosed = errors.New("cache: store is closed") )
Functions ¶
This section is empty.
Types ¶
type Config ¶ added in v0.2.0
type Config struct {
// Directory for persistent storage (derived from DB path).
DataDir string
// contains filtered or unexported fields
}
Config holds cache configuration options.
type LocalCache ¶
LocalCache provides in-memory caching for store implementations.
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
MemoryStore implements Store interface using in-memory storage
func (*MemoryStore) CleanAndCount ¶
CleanAndCount removes old timestamps and returns the count of remaining ones
func (*MemoryStore) Delete ¶
func (s *MemoryStore) Delete(ctx context.Context, key string) error
Delete removes a value from cache
type Store ¶
type Store interface {
Get(ctx context.Context, key string, value any) error
Set(ctx context.Context, key string, value any, expiration time.Duration) error
Delete(ctx context.Context, key string) error
Increment(ctx context.Context, key string, timestamp int64) error
CleanAndCount(ctx context.Context, key string, windowStart int64) error
GetCount(ctx context.Context, key string) (int64, error)
Expire(ctx context.Context, key string, expiration time.Duration) error
Close() error
}
Store defines the caching operations. Implementations must be safe for concurrent use.
Click to show internal directories.
Click to hide internal directories.