-
-
Notifications
You must be signed in to change notification settings - Fork 17
Add stack cache tags #419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+5,894
−537
Merged
Add stack cache tags #419
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
d109248
docs: add stack cache tags implementation plan
binaryfire d93bce8
cache: split tag set hierarchy
binaryfire 0efe2e2
redis-cache: split tagged caches and sync tag metadata
binaryfire 93cf0d4
cache: add honest capability probes
binaryfire 9965d7c
cache: add tags and locks to stack stores
binaryfire f2f6db3
jwt: support any-mode tagged blacklist storage
binaryfire 02f4e28
auth: allow any-mode stack cache tags
binaryfire 425edb3
docs: document stack cache tag semantics
binaryfire 0dfee66
docs: describe auth cache stack tag support
binaryfire ca2030b
docs: clarify JWT blacklist cache staleness
binaryfire 03d328d
test: guard stack tag integration cleanup
binaryfire 10c8b1a
fix: address stack cache tag review feedback
binaryfire 1735c57
Fix tagged touch cached null handling
binaryfire 9aea4c6
Broaden Redis tag doctor hash expiration check
binaryfire c89b807
Harden Redis hash expiration doctor probe
binaryfire File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
2,325 changes: 2,325 additions & 0 deletions
2,325
docs/plans/2026-07-06-stack-cache-tags-and-tag-architecture-refactor.md
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Hypervel\Cache; | ||
|
|
||
| use BadMethodCallException; | ||
| use DateInterval; | ||
| use DateTimeInterface; | ||
| use UnitEnum; | ||
|
|
||
| /** | ||
| * Tagged cache for any-mode tag semantics. | ||
| * | ||
| * Tags are invalidation indexes only: items live under their plain cache | ||
| * keys, tags are recorded on writes, and flushing any one tag removes every | ||
| * item written with it. Reads, existence checks, per-key deletes, and TTL | ||
| * adjustments are not tag operations in this mode. | ||
| */ | ||
| abstract class AnyModeTaggedCache extends TaggedCache | ||
| { | ||
| /** | ||
| * Retrieve an item from the cache by key. | ||
| * | ||
| * @throws BadMethodCallException always - tags are for writing and flushing only | ||
| */ | ||
| public function get(array|UnitEnum|string $key, mixed $default = null): mixed | ||
| { | ||
| throw new BadMethodCallException( | ||
| 'Cannot get items via tags in any mode. Tags are for writing and flushing only. ' | ||
| . 'Use Cache::get() directly with the full key.' | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * @throws BadMethodCallException always - tags are for writing and flushing only | ||
| */ | ||
| public function getRaw(UnitEnum|string $key): mixed | ||
| { | ||
| throw new BadMethodCallException( | ||
| 'Cannot get items via tags in any mode. Tags are for writing and flushing only. ' | ||
| . 'Use Cache::get() directly with the full key.' | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Retrieve multiple items from the cache by key. | ||
| * | ||
| * @throws BadMethodCallException always - tags are for writing and flushing only | ||
| */ | ||
| public function many(array $keys): array | ||
| { | ||
| throw new BadMethodCallException( | ||
| 'Cannot get items via tags in any mode. Tags are for writing and flushing only. ' | ||
| . 'Use Cache::many() directly with the full keys.' | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * @throws BadMethodCallException always - tags are for writing and flushing only | ||
| */ | ||
| public function manyRaw(array $keys): array | ||
| { | ||
| throw new BadMethodCallException( | ||
| 'Cannot get items via tags in any mode. Tags are for writing and flushing only. ' | ||
| . 'Use Cache::many() directly with the full keys.' | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Determine if an item exists in the cache. | ||
| * | ||
| * @throws BadMethodCallException always - tags are for writing and flushing only | ||
| */ | ||
| public function has(array|UnitEnum|string $key): bool | ||
| { | ||
| throw new BadMethodCallException( | ||
| 'Cannot check existence via tags in any mode. Tags are for writing and flushing only. ' | ||
| . 'Use Cache::has() directly with the full key.' | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Retrieve an item from the cache and delete it. | ||
| * | ||
| * @throws BadMethodCallException always - tags are for writing and flushing only | ||
| */ | ||
| public function pull(UnitEnum|string $key, mixed $default = null): mixed | ||
| { | ||
| throw new BadMethodCallException( | ||
| 'Cannot pull items via tags in any mode. Tags are for writing and flushing only. ' | ||
| . 'Use Cache::pull() directly with the full key.' | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Remove an item from the cache. | ||
| * | ||
| * @throws BadMethodCallException always - tags are for writing and flushing only | ||
| */ | ||
| public function forget(UnitEnum|string $key): bool | ||
| { | ||
| throw new BadMethodCallException( | ||
| 'Cannot forget items via tags in any mode. Tags are for writing and flushing only. ' | ||
| . 'Use Cache::forget() directly with the full key, or flush() to remove all tagged items.' | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Set the expiration of a cached item. | ||
| * | ||
| * @throws BadMethodCallException always - tags are for writing and flushing only | ||
| */ | ||
| public function touch(UnitEnum|string $key, DateInterval|DateTimeInterface|int|null $ttl = null): bool | ||
| { | ||
| throw new BadMethodCallException( | ||
| 'Cannot touch items via tags in any mode. Re-put the item through tags() to change ' | ||
| . 'its TTL; a direct Cache::touch() uses the store\'s plain-key semantics.' | ||
| ); | ||
| } | ||
| } |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Hypervel\Cache; | ||
|
|
||
| /** | ||
| * Base for tag sets whose tags namespace the item keyspace. | ||
| * | ||
| * Items are stored under keys derived from the tag set and must be read | ||
| * back through the same tags. | ||
| */ | ||
| abstract class NamespacedTagSet extends TagSet | ||
| { | ||
| /** | ||
| * Get a unique namespace that changes when any of the tags are flushed. | ||
| */ | ||
| public function getNamespace(): string | ||
| { | ||
| return implode('|', $this->tagIds()); | ||
| } | ||
|
|
||
| /** | ||
| * Get an array of tag identifiers for all of the tags in the set. | ||
| * | ||
| * @return array<string> | ||
| */ | ||
| public function tagIds(): array | ||
| { | ||
| return array_map([$this, 'tagId'], $this->names); | ||
| } | ||
|
|
||
| /** | ||
| * Get the unique tag identifier for a given tag. | ||
| */ | ||
| abstract public function tagId(string $name): string; | ||
|
|
||
| /** | ||
| * Get the tag identifier key for a given tag. | ||
| */ | ||
| abstract public function tagKey(string $name): string; | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.