Documentation
¶
Overview ¶
Package cache provides the storage layer behind mirava-core probes: a small interface implemented by a bounded in-memory LRU and an atomic-write disk layer, plus a singleflight guard so concurrent lookups share one upstream fetch.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultDir ¶
func DefaultDir() string
DefaultDir returns the OS cache location for mirava-core, e.g. ~/Library/Caches/mirava-core on macOS or ~/.cache/mirava-core on Linux.
Types ¶
type Disk ¶
type Disk struct {
// contains filtered or unexported fields
}
Disk is a persistent store under a root directory. Files are written atomically (temp file + rename) so a crash — or a second process sharing the cache — never observes a torn value.
type LRU ¶
type LRU struct {
// contains filtered or unexported fields
}
LRU is a bounded least-recently-used in-memory store. Entries are evicted when either the entry count or total byte size exceeds the limits.
type Layered ¶
type Layered struct {
// contains filtered or unexported fields
}
Layered composes a fast store (memory) over a slower one (disk). Gets promote disk hits into the fast layer WITHOUT extending their original expiry — the disk entry's ExpiresAt is preserved exactly.
type Store ¶
type Store interface {
// Get returns the entry and whether it was present at all. Expiry is
// checked by callers (so promotion never re-extends TTL).
Get(key string) (Entry, bool)
// Put stores the entry, replacing any previous value for key.
Put(key string, e Entry)
// Delete removes key if present.
Delete(key string)
}
Store is the cache contract. Implementations must be safe for concurrent use. mirava-core provides LRU (memory) and Disk; callers may supply their own (e.g. Redis-backed) via mirava.WithCache.