feat(cache): add ListableCache interface for enumerating cache keys#940
Open
ecordell wants to merge 1 commit into
Open
feat(cache): add ListableCache interface for enumerating cache keys#940ecordell wants to merge 1 commit into
ecordell wants to merge 1 commit into
Conversation
Adds an optional ListableCache interface to the service package for caches that are able to enumerate the keys they hold. Consumers detect support via type assertion on caches obtained from *Resources.AccessCache; the air gap, metrics and reverse air gap wrappers only expose ListKeys when the underlying cache implements it. The memory, file, aws_s3 and gcp_cloud_storage caches implement the new interface, as does the mock cache provided by MockResourcesOptAddCache. The cache metrics wrapper emits standard cache metrics for the list_keys operation, and a CacheTestListKeys definition is added to the integration test framework.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Adds an optional
ListableCacheinterface to theservicepackage for caches that are able to enumerate the keys they hold:Not all caches can support key listing, so support is detected via type assertion on the cache obtained from
*Resources.AccessCache. The air gap, metrics and reverse air gap wrappers propagate the capability only when the underlying cache implements it, so the assertion stays truthful through the whole chain. The metrics wrapper emits the standard cache metrics withoperation="list_keys".Implementations included:
memory(walks shards, omits TTL-expired items to matchGetsemantics),file(recursive directory walk),aws_s3(paginatedListObjectsV2with the cache's existing backoff pattern) andgcp_cloud_storage(bucket object iterator). The mock cache behindMockResourcesOptAddCachealso implements it so plugin authors can test listable-cache consumers.Motivation: components consuming a cache resource currently have no way to enumerate its contents, so patterns like "replay everything stored in this cache" require maintaining a separate index entry alongside the cached items. A follow-up PR adds a
cacheinput built on this interface.Testing
ListKeysunit tests formemory(including shards and TTL expiry) andfile(including nested directories)CacheTestListKeysintegration test definition, wired into theaws_s3localstack suite and verified locally