MCPcopy
hub / github.com/dosco/graphjin / MemoryCache

Struct MemoryCache

serv/cache_memory.go:28–50  ·  view source on GitHub ↗

MemoryCache provides in-memory LRU response caching with row-level invalidation

Source from the content-addressed store, hash-verified

26
27// MemoryCache provides in-memory LRU response caching with row-level invalidation
28type MemoryCache struct {
29 cache *lru.Cache[string, *memoryCacheEntry]
30 conf CachingConfig
31 metrics *CacheMetrics
32 excludeTable map[string]bool
33 workerPool *SWRWorkerPool
34
35 // Dependency index: dependency key -> set of fragment keys
36 rowIndex map[string]map[string]struct{}
37 tableIndex map[string]map[string]struct{}
38 modTimes map[string]int64 // dependency key -> modification timestamp (ms)
39 cacheMu sync.Mutex
40 mu sync.RWMutex
41
42 // OpenTelemetry metric instruments
43 otelHitCounter metric.Int64Counter
44 otelMissCounter metric.Int64Counter
45 otelInvalidationCounter metric.Int64Counter
46 otelErrorCounter metric.Int64Counter
47 otelSWRRefreshCounter metric.Int64Counter
48 otelBytesCachedGauge metric.Int64UpDownCounter
49 otelBytesSavedGauge metric.Int64UpDownCounter
50}
51
52// NewMemoryCache creates a new in-memory LRU cache
53func NewMemoryCache(conf CachingConfig, maxEntries int) (*MemoryCache, error) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected