Simone Scarduzio
|
47f022fffe
|
feat: Add programmatic cache management for long-running applications
Implements cache clearing functionality for SDK users who need manual
cache management in long-running applications where automatic cleanup
on process exit is not sufficient.
New Features:
- Added `clear()` method to CachePort protocol
- Implemented `clear()` in all cache adapters:
* ContentAddressedCache: Clears files and SHA mappings
* EncryptedCache: Clears encryption mappings and delegates to backend
* MemoryCache: Already had clear() method
- Added `clear_cache()` method to DeltaGliderClient for public API
Cache Management API:
```python
from deltaglider import create_client
client = create_client()
# Upload files
client.put_object(Bucket='bucket', Key='file.zip', Body=data)
# Clear cache manually (important for long-running apps!)
client.clear_cache()
```
New Documentation:
- docs/CACHE_MANAGEMENT.md (684 lines)
* Comprehensive guide for programmatic cache management
* Long-running application strategies (web apps, services, batch jobs)
* Encryption key management (ephemeral vs. persistent)
* Key rotation procedures
* Memory vs. filesystem cache trade-offs
* Best practices by application type
* Monitoring and troubleshooting
Key Topics Covered:
- Why SDK requires manual cache management (vs. CLI auto-cleanup)
- When to clear cache (periodic, config changes, tests, etc.)
- Cache strategies for 5 application types:
* Long-running background services
* Periodic batch jobs
* Web applications / API servers
* Testing / CI/CD
* AWS Lambda / Serverless
- Encryption key management:
* Ephemeral keys (default, maximum security)
* Persistent keys (shared cache scenarios)
* Key rotation procedures
* Secure key storage (Secrets Manager)
- Memory vs. filesystem cache selection
- Monitoring cache health
- Troubleshooting common issues
Use Cases:
- Long-running services: Periodic cache clearing to prevent growth
- Batch jobs: Clear cache in finally block
- Tests: Clear cache after each test for clean state
- Multi-process: Shared cache with persistent encryption keys
- High performance: Memory cache with automatic LRU eviction
Security Enhancements:
- Documented encryption key lifecycle management
- Key rotation procedures
- Secure key storage best practices
- Ephemeral vs. persistent key trade-offs
Testing:
- All 119 tests passing ✅
- Type checking: 0 errors (mypy) ✅
- Linting: All checks passed (ruff) ✅
Breaking Changes: None (new API only)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
2025-10-10 10:34:02 +02:00 |
|