Skip to content

Fix prefix-based cache invalidation #79

Description

@Lakes41

Difficulty: Hard

Type: Bug

Summary

Fix cache invalidation so guild-scoped and wallet-scoped entries are actually removed when invalidation helpers are called.

Current Behaviour

invalidateGuildCache builds prefix-like cache keys such as access:checkAccess:${guildId}:, then calls cache.delete(key). The cache adapter only deletes exact keys, so entries like access:checkAccess:prime-guild:premium-docs:0x... are not removed.

Expected Behaviour

Invalidation helpers should remove all matching cache entries for the target guild or wallet without requiring a full cache clear unless the adapter cannot support targeted deletion.

Suggested Implementation

Extend the cache adapter contract with an optional deleteByPrefix(prefix: string) method. Implement prefix deletion in InMemoryCacheAdapter. Update invalidateGuildCache to use prefix deletion when available and document fallback behaviour for custom adapters.

Files or Areas Likely Affected

  • src/client/GuildPassClient.ts
  • src/cache/cache.types.ts
  • tests/
  • docs/sdk-guide.md

Acceptance Criteria

  • invalidateGuildCache removes all access, membership, role, and guild entries for the target guild
  • InMemoryCacheAdapter supports prefix deletion
  • Custom adapters can opt into targeted prefix deletion
  • Fallback behaviour is documented for adapters without prefix support
  • Tests prove stale guild cache entries are not returned after invalidation
  • Existing clearCache behaviour remains unchanged

Additional Notes

This issue is separate from adding pluggable caching. It focuses on correctness of the cache invalidation helpers that already exist.

Metadata

Metadata

Assignees

No one assigned

    Labels

    GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official Campaign

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions