-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Labels
Description
Extend the CacheClient with a proper cache invalidation strategy, including support for tagged invalidation groups and configurable TTL policies per data type.
Requirements:
- Add the following methods to
CacheClient:set_with_tags(key: &str, value: &T, ttl: u64, tags: &[&str]) -> Result<()>— stores the value and also adds the key to a Redis set for each tag (tag:<name>→ set of keys)invalidate_by_tag(tag: &str) -> Result<usize>— deletes all keys associated with the tag and removes the tag set; returns the count of deleted keysdelete(key: &str) -> Result<()>— delete a single keyextend_ttl(key: &str, additional_seconds: u64) -> Result<()>— extend expiry of an existing keyget_ttl(key: &str) -> Result<Option<u64>>— return remaining TTL in seconds
- Define a
CacheTtlconstants module:pub mod cache_ttl { pub const VERIFICATION_RESULT: u64 = 3600; // 1 hour pub const TRANSFER_HISTORY: u64 = 300; // 5 minutes pub const HASH_HISTORY: u64 = 300; // 5 minutes }
- Use tag
document:<hash>for all cache entries related to a document hash so they can be bulk-invalidated
Acceptance Criteria:
invalidate_by_tagdeletes all keys tagged with the given tag in a single operationextend_ttlon a non-existent key is a no-op (does not create the key)- Unit tests using a mock Redis (or an actual embedded Redis in tests)
- All existing call sites updated to use the new
set_with_tagsand the constants
Reactions are currently unavailable