Skip to content

fix: prefix-based cache invalidation for guild and wallet scopes (#79)#101

Merged
Lakes41 merged 1 commit into
Adamantine-guild:mainfrom
GBOYEE:fix/prefix-cache-invalidation-79
Jun 27, 2026
Merged

fix: prefix-based cache invalidation for guild and wallet scopes (#79)#101
Lakes41 merged 1 commit into
Adamantine-guild:mainfrom
GBOYEE:fix/prefix-cache-invalidation-79

Conversation

@GBOYEE

@GBOYEE GBOYEE commented Jun 26, 2026

Copy link
Copy Markdown

Summary

  • Add optional deleteByPrefix to CacheAdapter interface
  • Implement deleteByPrefix in InMemoryCacheAdapter
  • Fix invalidateGuildCache to use prefix deletion (was only deleting exact keys, missing composite keys like access:checkAccess:guild:resource:wallet)
  • Fix invalidateWalletCache to use prefix deletion instead of clearing entire cache
  • Graceful fallback to exact-key delete for legacy adapters without deleteByPrefix

Bug

invalidateGuildCache built prefix keys but called cache.delete(key) which only removes exact matches. Composite cache entries with wallet/resource suffixes were never removed.

Tests added

  • deleteByPrefix removes all matching keys, preserves others
  • invalidateGuildCache removes composite-key entries via prefix
  • invalidateWalletCache uses prefix deletion, preserves other wallets
  • Fallback to exact delete for adapters without deleteByPrefix

Closes #79

…mantine-guild#79)

- Add optional deleteByPrefix to CacheAdapter interface
- Implement deleteByPrefix in InMemoryCacheAdapter
- Update invalidateGuildCache to use deleteByPrefix (fixes composite key deletion)
- Update invalidateWalletCache to use prefix deletion instead of full clear
- Fallback to exact-key delete for legacy adapters without deleteByPrefix
- Add comprehensive tests for prefix deletion and edge cases

Closes Adamantine-guild#79

@Lakes41 Lakes41 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty Well done

@Lakes41 Lakes41 merged commit 805b48b into Adamantine-guild:main Jun 27, 2026
0 of 3 checks passed
@grantfox-oss grantfox-oss Bot mentioned this pull request Jun 27, 2026
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix prefix-based cache invalidation

2 participants