diskcache

Disk and file backed cache library for Python. diskcache stores cache values in SQLite with optional file storage for large values, providing persistent caching that survives process restarts. Faster than Redis for local access patterns, thread-safe and multiprocess-safe. Supports TTL expiry, cache size limits, eviction policies, and memoization decorators. Zero dependencies, pure Python.

Evaluated Mar 06, 2026 (0d ago) v5.6+
Homepage ↗ Repo ↗ Developer Tools cache python disk sqlite persistence key-value fast ttl
⚙ Agent Friendliness
66
/ 100
Can an agent use this?
🔒 Security
80
/ 100
Is it safe for agents?
⚡ Reliability
84
/ 100
Does it work consistently?

Score Breakdown

⚙ Agent Friendliness

MCP Quality
--
Documentation
84
Error Messages
80
Auth Simplicity
95
Rate Limits
95

🔒 Security

TLS Enforcement
85
Auth Strength
80
Scope Granularity
75
Dep. Hygiene
85
Secret Handling
78

Local disk storage — no network exposure. Cached data is unencrypted on disk; sensitive agent data should be encrypted before caching. File system permissions control access.

⚡ Reliability

Uptime/SLA
86
Version Stability
85
Breaking Changes
82
Error Recovery
84
AF Security Reliability

Best When

You need persistent local caching for agent results that survives restarts, with no external dependencies and multiprocess safety on a single machine.

Avoid When

You need distributed caching across agent nodes or sub-millisecond latency — use Redis. Also avoid for production at high throughput where Redis performance matters.

Use Cases

  • Cache agent API responses persistently across restarts without a Redis server — diskcache survives process restarts unlike in-memory caches
  • Use diskcache's FanoutCache for high-throughput agent caching with multiple underlying cache shards for concurrent agent worker processes
  • Memoize expensive agent computations with @cache.memoize() decorator for persistent result caching across agent invocations
  • Cache large agent artifacts (embeddings, processed documents) to disk as a cost-effective alternative to in-memory Redis for GB-scale data
  • Use diskcache in Docker containers for persistent caching between container restarts when Redis is not available in the deployment

Not For

  • Distributed caching across multiple hosts — diskcache is single-machine only; use Redis or Memcached for distributed cache
  • Sub-millisecond latency requirements — diskcache has disk I/O overhead; in-memory caches are faster for hot-path caching
  • Shared cache across multiple machines in agent clusters — diskcache is local process cache; Redis is required for cross-node sharing

Interface

REST API
No
GraphQL
No
gRPC
No
MCP Server
No
SDK
Yes
Webhooks
No

Authentication

Methods: none
OAuth: No Scopes: No

Local disk cache — no authentication. File system permissions control access.

Pricing

Model: open_source
Free tier: Yes
Requires CC: No

Community-maintained open source. Apache 2.0 license.

Agent Metadata

Pagination
none
Idempotent
Full
Retry Guidance
Not documented

Known Gotchas

  • diskcache's default directory is platform-specific — always specify an explicit directory path to avoid cache data in unexpected locations across environments
  • Cache objects must be closed with cache.close() or used as a context manager — not closing leaves SQLite connections open and file handles unclosed
  • Multiprocess caching works correctly but concurrent writes to the same key create lock contention — FanoutCache shards the keyspace to reduce contention for high-concurrency agent workloads
  • Large values (>1KB by default) are stored as files, not in SQLite — the threshold is configurable; file storage requires disk space management and cleanup via cache.cull()
  • diskcache's eviction happens lazily on access — the cache may temporarily exceed size_limit before culling; don't rely on precise size enforcement for critical storage limits
  • Pickle is the default serialization — caching non-picklable objects (lambdas, sockets, file handles) raises PicklingError silently consuming the cache miss path

Alternatives

Full Evaluation Report

Comprehensive deep-dive: security analysis, reliability audit, agent experience review, cost modeling, competitive positioning, and improvement roadmap for diskcache.

AI-powered analysis · PDF + markdown · Delivered within 30 minutes

$99

Package Brief

Quick verdict, integration guide, cost projections, gotchas with workarounds, and alternatives comparison.

Delivered within 10 minutes

$3

Score Monitoring

Get alerted when this package's AF, security, or reliability scores change significantly. Stay ahead of regressions.

Continuous monitoring

$3/mo

Scores are editorial opinions as of 2026-03-06.

5229
Packages Evaluated
26151
Need Evaluation
173
Need Re-evaluation
Community Powered