-
Notifications
You must be signed in to change notification settings - Fork 84
Add manual cache invalidation API to watchAndInvalidate #328
Copy link
Copy link
Closed
Adamantine-guild/guildpass-sdk
#443Labels
GrantFox OSSGrantFox Open Source Sponsorship program tagGrantFox Open Source Sponsorship program tagMaybe RewardedIssue may qualify for a reward upon successful completion per campaign rulesIssue may qualify for a reward upon successful completion per campaign rulesThird CampaignOfficial FWC26 campaign issue — eligible for campaign scoring and rewardsOfficial FWC26 campaign issue — eligible for campaign scoring and rewards
Description
Activity
Metadata
Metadata
Assignees
Labels
GrantFox OSSGrantFox Open Source Sponsorship program tagGrantFox Open Source Sponsorship program tagMaybe RewardedIssue may qualify for a reward upon successful completion per campaign rulesIssue may qualify for a reward upon successful completion per campaign rulesThird CampaignOfficial FWC26 campaign issue — eligible for campaign scoring and rewardsOfficial FWC26 campaign issue — eligible for campaign scoring and rewards
Difficulty: Intermediate
Type: Feature
Recommended labels (if available in this repo):
enhancement,caching,sdkBackground
src/contracts/watchAndInvalidate.tsappears to handle automatic cache invalidation based on on-chain events. There is currently no way for a consumer to manually force-invalidate a cache entry (e.g. after performing a mutation through another path, like an admin action inguildpass-integrations).Problem
If a consumer application changes on-chain or off-chain state through a path the SDK isn't watching (e.g. a direct admin API call), the SDK's cache can serve stale data until the next automatic invalidation trigger fires.
Expected Outcome
A public
client.cache.invalidate(key | pattern)method that lets consumers manually evict specific cache entries or entries matching a pattern (e.g. by wallet address or guild ID).Suggested Implementation
Expose an
invalidatemethod on the client that delegates to the configured cache adapter'sdelete/clearmethods, and extendwatchAndInvalidate.tsto support a pattern-based invalidation helper if the underlying cache doesn't natively support pattern matching (e.g. by tracking key prefixes).Acceptance Criteria
client.cache.invalidate()is implemented and exportedpnpm test:runpassesLikely Affected Files/Directories
src/contracts/watchAndInvalidate.tssrc/cache/cache.types.tssrc/client/GuildPassClient.ts