feat(redis): add TTL support for Redis KV storage #2490
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Add configurable TTL (Time-To-Live) support for Redis storage implementations. This allows users to set an expiration time for cached data in Redis, which is useful for managing memory usage and ensuring stale data is automatically removed.
This is particularly useful for organizations that have internal data retention policies requiring cached data to expire after a specific period. By configuring the TTL, users can ensure compliance with their company's data governance requirements while also managing Redis memory usage more effectively.
Changes Made
REDIS_TTLenvironment variable to configure key expiration time (default:0= no expiration)setoperations inRedisKVStorage.upsert()methodsetoperations inRedisDocStatusStorage.upsert()methodRedisKVStorage._migrate_legacy_cache_structure()86400for 24 hours,604800for 7 days)Checklist
Additional Notes
Usage
Set the
REDIS_TTLenvironment variable to enable key expiration:When
REDIS_TTLis set to0(default), keys will never expire, maintaining backward compatibility with existing behavior.