Self-tuning Valkey for AI agents

LLM call caching for AI agents. Historical slowlog, anomaly detection, and pattern analysis for ops. Debug what happened at 3am, not just what's happening now.

Cache intelligenceAgent cachingVector workload observabilityPersistent monitoring

For AI

@betterdb/agent-cache
npm install @betterdb/agent-cache iovalkey

TypeScript. Multi-tier LLM, tool, and session caching. OTel + Prometheus built in.

@betterdb/semantic-cache
npm install @betterdb/semantic-cache iovalkey

TypeScript. Similarity-based caching with valkey-search.

For Ops

claude mcp add betterdb -- \
  npx @betterdb/mcp betterdb-mcp \
  --autostart --persist

Adds BetterDB as an MCP server to Claude Code. Starts monitoring automatically.

Then ask Claude about your database health, slow queries, or memory usage.

Or use BetterDB Cloud, no setup required →

The cache tunes itself

No other Valkey or Redis cache library does this.

Agent(via MCP)Reads hit rate, similaritydistribution, tool effectivenessProposal queue Threshold, TTL adjust,or targeted invalidationHuman approves Reviews reasoning inBetterDB MonitorValkey HSET {name}:__configthreshold, tool policiesCache library Polls config, applieswithin seconds, no restartobserves new behavior

Agent MCP call

// Agent MCP call
await mcp.callTool(
  'cache_propose_threshold_adjust',
  {
    cache_name: 'prod-semantic',
    new_threshold: 0.075,
    reasoning:
      'hit rate 28% over 7d,'
      + ' tighten threshold',
  }
)

Pending proposal

// Pending proposal (API response)
{
  "id": "prop_01jwx3krq5",
  "status": "pending",
  "cache_name": "production-semantic",
  "new_threshold": 0.075,
  "expires_at": "2026-05-06T12:00:00Z",
  "warnings": []
}

After approval

// Dispatcher writes to Valkey:
HSET production-semantic:__config \
  threshold 0.075

// Library picks up the change
// within seconds. No restart.

The agent observes live cache metrics via MCP read tools, proposes a config change with reasoning, and a human approves it in BetterDB Monitor. The cache library polls its config key in Valkey and swaps the policy atomically - no restart, no redeploy. Config polling is live in @betterdb/semantic-cache@0.4.0 and @betterdb/agent-cache@0.6.0. See the full closed-loop example

Why teams choose BetterDB for agent caching

Three cache tiers behind one Valkey connection. No modules required.

Capability@betterdb/agent-cacheLangChain RedisCacheLangGraph checkpoint-redisAutoGen RedisStoreLiteLLM RedisUpstash + Vercel AI SDK
Agent-tunable via MCP
Live config updates (no restart)
Multi-tier (LLM + Tool + State)LLM onlyState onlyLLM onlyLLM onlyLLM only
Built-in OTel + PrometheusPartial
No modules requiredRedis 8 + modulesUpstash only
Base SDK support (OpenAI, Anthropic)
Multi-modal (images, audio, files)
Language supportTypeScript + PythonTS onlyTS onlyPython onlyPython onlyTS only
Framework adaptersOpenAI, Anthropic, LangChain, LangGraph, LlamaIndex, VercelLC onlyLG onlyAutoGen onlyLiteLLM onlyAI SDK only
Zero-config cost trackingBundled LiteLLM table, 1,900+ models

AI Caching

Two caching strategies, one Valkey instance, full observability.

@betterdb/agent-cachebetterdb-agent-cache

Exact-match caching

Three cache tiers: LLM responses, tool results, and session state. TypeScript and Python. Works with OpenAI, Anthropic, LangChain, LangGraph, LlamaIndex, and (TS) Vercel AI SDK.

@betterdb/agent-cache
npm
npm install @betterdb/agent-cache iovalkey
pip
pip install betterdb-agent-cache
@betterdb/semantic-cachebetterdb-semantic-cache

Semantic caching

Similarity-based response caching with adapter parity for OpenAI, Anthropic, LangChain, LangGraph, LlamaIndex, and Vercel AI SDK. Bundled cost tracking, auto-tuning threshold recommendations, and embedding cache. TypeScript and Python.

betterdb-semantic-cache
npm
npm install @betterdb/semantic-cache iovalkey
pip
pip install betterdb-semantic-cache

See what's actually happening inside your Valkey or Redis instance

Historical data that survives a log rotation. Client-level attribution. Automatic anomaly detection.

BetterDB Slowlog pattern analysis showing pattern distribution, command breakdown and key prefix breakdown with historical date range filter

500 slow queries, 114 unique patterns, 19 command types - across any historical time range. The evidence that used to disappear after a log rotation.

Built for humans and agents alike

Investigate incidents yourself - or point your agent at BetterDB and walk away.

For agents

Your agent investigates and proposes

Connect BetterDB's MCP server to Claude Code, Cursor, or any MCP-compatible client. The agent reads live cache state - hit rate, similarity distribution, per-tool effectiveness - and can propose threshold tightenings, TTL adjustments, and targeted invalidations. Humans approve; changes go live within seconds.

{
  "mcpServers": {
    "betterdb": {
      "command": "npx",
      "args": ["-y", "@betterdb/mcp"]
    }
  }
}
For humans

You oversee and approve

Full dashboard, slowlog pattern analysis, anomaly detection, client attribution, vector search, and vector workload health. Review and approve agent-proposed cache optimizations in the BetterDB Monitor proposal queue - you see the reasoning, the expected outcome, and can edit before approving.

BetterDB dashboard - memory, CPU, ops timeline, slowlog markers, and anomaly flags
Get Started for Free →

Everything you need to understand your Valkey or Redis instance

Deep insights into your Valkey or Redis deployment with minimal overhead.

Anomaly Detection

Automatic detection of unusual patterns across memory, CPU, and connections.

Historical Analytics

Query what happened at 3am, not just what's happening now.

Cluster Visualization

Interactive topology graphs, slot heatmaps, and migration tracking.

ACL Audit Trail

Track who accessed what for compliance and debugging.

Slowlog & COMMANDLOG

Pattern analysis across persisted slow queries and full command history. Valkey 8.1+ COMMANDLOG captures every command, not just the slowest ones.

Key Analytics

Analyze key patterns by namespace and key type.

Client Analytics

See which clients consume resources. Detect unusual buffer sizes and connection spikes.

Prometheus & Webhooks

107 Prometheus metrics plus Slack, email, and webhook notifications.

Vector Workload Analytics

FT.SEARCH ops/sec and latency over time, per-index health with alerts for indexing failures, backfill progress, and deleted-doc growth. Built for teams running RAG and semantic search in production.

Vector Search

Inspect vector indexes, browse embeddings, and find semantically similar entries with similarity scores.

Cache Proposals

Proposal queue and audit trail for agent-submitted cache optimizations. Review, edit, and approve threshold and TTL changes directly in BetterDB Monitor.

MCP Server

Full observability and cache intelligence tools from any MCP-compatible client - Claude Code, Cursor, IDEs. Agents read cache state and propose optimizations directly.

View on registry →

Inference Pipeline Latency

Per-operation P50/P95/P99 profiles for FT.SEARCH, reads, and writes. Per-index SLA thresholds with webhook breach alerts - know before users do.

Hot Key Tracking

Top-50 keys by access frequency with rank movement over time. Spot what's climbing before it becomes a bottleneck.

Latency Monitoring

Per-event latency history across P50/P95/P99. Know when your instance started slowing down, not just that it is.

CPU & I/O Threads

Per-thread I/O metrics and CPU utilization charts, including Valkey 8.x I/O thread breakdowns.

Migration

Analyze compatibility, move data, and validate results across Redis, Valkey, cloud, and self-hosted - in any direction.

Throughput Forecasting

Growth rate trend and ceiling-based ops/sec forecasting. Get alerted before you hit capacity, not after.

Our goal: zero hacks for Valkey or Redis

If you've ever written a custom script, stitched together three tools, or just accepted that something wasn't observable - we want to hear about it. Tell us what's missing. We'll build it, and the next person won't have to figure it out themselves.

Book 15 min with Kristiyan

Prefer email? kristiyan@betterdb.com

Free during early access - every Pro and Enterprise feature is unlocked while we're in beta.

Ready to get started?

Start monitoring in minutes - no infrastructure to maintain. Team collaboration, agent-based monitoring for private databases, and more. Or self-host - open source core, zero lock-in.