Skip to content

In memory cache#114

Open
gloskull wants to merge 2 commits into
VeriNode-Labs:mainfrom
gloskull:In-memory-Cache
Open

In memory cache#114
gloskull wants to merge 2 commits into
VeriNode-Labs:mainfrom
gloskull:In-memory-Cache

Conversation

@gloskull

Copy link
Copy Markdown

Motivation

  • Provide a deterministic, dependency-free in-memory cache for critical paths with configurable TTL and capacity to reduce upstream load and meet latency budgets.
  • Allow off-chain services to swap in a Redis-backed adapter without changing call sites by carrying Redis deployment settings alongside the in-process config.
  • Expose basic observability (hits/misses/evictions/expirations) and a rollout/runbook to support blue-green/canary deployments and monitoring.

Description

  • Add a new cache module src/db/cache.rs implementing CacheConfig, RedisCacheConfig, CacheMetrics, and a generic TtlCache<K,V> with per-entry TTL overrides, expiry on access, bounded capacity eviction, and metrics.
  • Export the new module via pub mod cache; in src/db/mod.rs and add a brief crate-level comment referencing the cache in src/lib.rs.
  • Add documentation CACHE_LAYER_ARCHITECTURE.md describing TTL policy, Redis deployment guidance, monitoring/alerting, rollout guidance, and runbook steps.
  • Include comprehensive unit tests in src/db/cache.rs covering TTL expiry, per-entry TTL overrides, capacity eviction, metrics, and Redis config defaults.

Testing

  • Ran cargo fmt and cargo test cache --lib to exercise the new cache unit tests and related library tests.
  • All executed unit tests passed (17 tests ran, 17 passed, 0 failed).
  • Verified formatting with cargo fmt before final tests.

Closes #71

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

In-memory Cache Layer with Redis and Configurable TTL

1 participant