Skip to content

feat: expose LRU cache hit/miss metrics - #664

Open
ZacLou wants to merge 10 commits into
conduit-protocol:mainfrom
ZacLou:feat/cache-metrics-611
Open

ZacLou wants to merge 10 commits into
conduit-protocol:mainfrom
ZacLou:feat/cache-metrics-611

Conversation

@ZacLou

@ZacLou ZacLou commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Addresses #611

Changes

Added getCacheMetrics() to both FactoryModule and StreamsModule (delegating to the factory):

interface CacheMetrics {
  hits: number;      // total cache hits (positive + negative)
  misses: number;    // total cache misses (contract calls made)
  size: number;      // current entries in the address cache
  hitRate: number;   // hits / (hits + misses), 0 if no requests
}

FactoryModule

  • Added _cacheHits and _cacheMisses private counters
  • Increment on every cache hit (positive hit returns cached address, negative hit returns null within TTL)
  • Increment _cacheMisses on every cache miss (falls through to contract call)
  • getCacheMetrics() returns { hits, misses, size, hitRate }
  • Counters reset in clearAddressCache()

StreamsModule

  • Added getCacheMetrics() proxy delegating to this._factory.getCacheMetrics()

Usage

const sdk = new ConduitClient(config);
const metrics = sdk.streams.getCacheMetrics();
console.log(`Hit rate: ${(metrics.hitRate * 100).toFixed(1)}%`);

Files changed

  • src/factory.ts - counters + getCacheMetrics()
  • src/streams.ts - getCacheMetrics() proxy

@ZacLou
ZacLou force-pushed the feat/cache-metrics-611 branch from 7178ce5 to 5aa8e7f Compare September 5, 2026 11:15
…uit-protocol#606)

- Export resolveFee from src/index.ts so consumers can compute effective fees
- Add fee and feeMultiplier rows to ConduitClient configuration table
- Add Fee Precedence section to README explaining the resolution order:
  explicit fee > feeMultiplier * BASE_FEE > BASE_FEE

Closes conduit-protocol#606
…l#627)

- Add .size-limit.json with 80KB gzip limit for index entry and 30KB for utils
- Add size-limit.yml GitHub Actions workflow (runs after build)
- Add @size-limit/preset-small-lib devDependency and size-limit npm script
…ol#613)

- Add typedoc.json configuration (entryPoints, output dir, sorting)
- Add docs.yml GitHub Actions workflow: builds typedoc on PR/push,
  deploys to GitHub Pages on main merge
- Add typedoc devDependency and docs npm script
- Exclude tests, private/protected members, and external deps from docs
- Add cron trigger (02:00 UTC daily) to the existing CI workflow
- Keeps existing push/PR triggers so E2E still runs on every change
- Nightly runs catch browser drift and flaky regressions without blocking PRs
…l#611)

- Add _cacheHits / _cacheMisses counters to FactoryModule
- Increment hit on positive/negative cache lookup, miss on RPC fallback
- Add getCacheMetrics() returning { hits, misses, size }
- Add resetCacheStats() for measurement windows
- Wire getCacheMetrics() through ConduitClient facade
- Returns null when factoryAddress was not configured
@ZacLou
ZacLou force-pushed the feat/cache-metrics-611 branch from 5aa8e7f to a1f4536 Compare September 6, 2026 01:14
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.

1 participant