feat(cache): add per-tool cache key prefixing and improve API clarity #99
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.
Summary
This PR adds per-tool cache key prefixing to prevent cache collisions between different tools using the same parameters, and improves Redis key organization with clearer hierarchy.
Fixes #91
Problem
Cache keys could clash between different tools when using the same parameters. For example, a weather tool and news tool both receiving
{ location: "NYC" }would generate the same cache key, causing incorrect cached results.Key Changes
New Features:
toolNameoption to namespace cache keys per toolkeySeparatoroption (default":")cacheKeyContextreplacescacheKey(better reflects it's a suffix)Breaking Changes:
keyPrefix→storeNamein RedisCacheStore and CacheBackendConfig"ai-tools-cache:"to"ai-tools-cache"(separator added automatically)keyGeneratorsignature changed from positional to object parametersDeprecations:
cacheKeydeprecated in favor ofcacheKeyContext(backward compatible)Migration Examples
keyGenerator
Usage Example
Keys structure:
storeName:toolName:params:contextNote: there are breaking changes, not sure if contributors are suppose to run changeset?