Files
mytheclipse/crates/mytheclipse-cache
asepharyana 1dfc6d6865 fix(ci): restore full CI green — test-matrix, clippy, rustfmt, and rustdoc gates
Root cause of the failing CI run was that examples/tests referencing
feature-gated items were auto-detected (no required-features), so
`--all-targets` compiled them under feature combinations where those
modules didn't exist. Fixes:

- mytheclipse Cargo.toml: declare the `high_level` example and
  `race_stress` integration test with required-features = ["full"];
  `cargo build --all-targets` now skips them when full is off. This
  clears the whole test-matrix (workspace default, all-features, and
  every single-feature config) which all failed on E0432/E0433.
- lib.rs: auto_metrics_service depends on service_builder, so regate it
  behind all(observability, resiliency) instead of observability alone
  (observability-only build compiled the module without resiliency).
- mytheclipse-tracing: gate `pub mod fmt` behind any
  tracing-subscriber-providing feature so --no-default-features compiles.
- mytheclipse-queue: gate `pub mod worker` behind in-memory (worker.rs
  requires tokio, only provided by in-memory).
- clippy -D warnings fixes: deprecated base64 0.22 free fns -> Engine
  (paseto), unused key field, needless mut (service_builder), unused
  import/dead var/missing is_empty (bg_join), dead is_expired (dlock),
  while-let-iterator->for (parallel_map), type_complexity (shutdown_guard),
  MutexGuard held across await (middleware, now clones Arc'd layers),
  if-let-Err->is_err (queue), unused CliBuilder fields now wired into clap.
- rustdoc -D warnings: resolve retry/MetricsBridge/CircuitBreaker/KeyRing
  intra-doc links and fix the unparseable lifecycle.rs code fence.
- cargo fmt --all to satisfy the Rustfmt gate.
2026-08-30 00:33:21 +07:00
..
2026-08-29 17:00:18 +00:00

mytheclipse-cache

A unified multi-layer cache abstraction so your app isn't locked to one cache provider. Combines an in-process L1 cache with a distributed L2 cache (e.g. Redis/Valkey) behind one simple get/set/invalidate API, plus a cache-aside / auto-refresh helper.

Features

  • l1-memory (default) — zero-dependency in-process cache.
  • l1-moka — high-performance Moka-backed L1 with TTL/max-capacity.
  • l2-redis — Redis/Valkey L2 via fred.
  • cache-aside (default) — read-through cache-aside helper.

Usage

use mytheclipse_cache::{Cache, MemoryCache, MultiLayerCache, CacheAside};

let cache = MultiLayerCache::new(
    MemoryCache::new(),          // L1
    MemoryCache::new(),          // L2 (use RedisCache in production)
);
cache.set("k", b"v".to_vec(), None).await.unwrap();
let v = cache.get("k").await.unwrap();

// Cache-aside: fill misses from a source of truth.
let aside = CacheAside::new(
    MemoryCache::new(),
    |key| async move { Some(format!("data-for-{key}").into_bytes()) },
);
let _ = aside.get("orders:42").await.unwrap();