-
Notifications
You must be signed in to change notification settings - Fork 3
feat: add TTL index to MongoDB store for automatic expiration #155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Adds a TTL index on the `expires_at` field in MongoDB collections to enable automatic cleanup of expired entries. MongoDB will delete expired documents approximately every 60 seconds using its built-in background process. This brings MongoDB's TTL handling in line with other stores like DynamoDB (which has native TTL) and Elasticsearch (which has manual cleanup). Benefits: - Automatic cleanup of expired entries without manual intervention - Reduced storage usage for expired data - Leverages MongoDB's native TTL index feature Related to #148 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: William Easton <[email protected]>
📝 WalkthroughWalkthroughTwo MongoDB store implementations (async and sync variants) now create indexes during collection setup: a standard index on the "key" field for lookups and a TTL index on "expires_at" with expireAfterSeconds set to 0 for automatic document expiration. No control flow modifications. Changes
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: ASSERTIVE Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used📓 Path-based instructions (6)**/*.py📄 CodeRabbit inference engine (AGENTS.md)
Files:
key-value/key-value-sync/**📄 CodeRabbit inference engine (AGENTS.md)
Files:
{key-value/key-value-aio/src/key_value/aio/stores/**,key-value/key-value-sync/src/key_value/sync/code_gen/stores/**}📄 CodeRabbit inference engine (AGENTS.md)
Files:
key-value/key-value-sync/src/key_value/sync/code_gen/stores/**📄 CodeRabbit inference engine (AGENTS.md)
Files:
key-value/key-value-aio/**📄 CodeRabbit inference engine (AGENTS.md)
Files:
key-value/key-value-aio/src/key_value/aio/stores/**📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧬 Code graph analysis (1)key-value/key-value-sync/src/key_value/sync/code_gen/stores/mongodb/store.py (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
🔇 Additional comments (2)
Comment |
|



Adds a TTL index on the
expires_atfield in MongoDB collections to enable automatic cleanup of expired entries. MongoDB will delete expired documents approximately every 60 seconds using its built-in background process.This brings MongoDB's TTL handling in line with other stores like DynamoDB (which has native TTL) and Elasticsearch (which has manual cleanup).
Benefits
Implementation
The TTL index is created during collection setup with
expireAfterSeconds=0, meaning documents will be deleted when the current time reaches the value in theexpires_atfield.Related to #148
🤖 Generated with Claude Code
Summary by CodeRabbit