Skip to content

chore(cache): improve invalidation logic - #45

Draft
sidux wants to merge 8 commits into
masterfrom
improve-cache-invalidation
Draft

chore(cache): improve invalidation logic#45
sidux wants to merge 8 commits into
masterfrom
improve-cache-invalidation

Conversation

@sidux

@sidux sidux commented Jul 8, 2024

Copy link
Copy Markdown
Contributor

Automatic cache tags include the property or method name, with optional explicit prefixes. Cache reads and invalidations use the same tag builder. Cache misses and hits expose their keys and tags for diagnostics.

The current cache configuration and reserved-character sanitization are preserved. Traversal tracks object identity, so cyclic graphs terminate and objects sharing an identifier still contribute their other tags and children. Regression tests verify invalidation through the real Symfony tag-aware cache adapter.

Validation: Composer validation, ECS, PHPStan, and all 82 tests (308 assertions) pass. The repository's existing Nix inputs required temporary local overrides for validation; those overrides are not included in this PR.

Remaining rollout work:

  • Add regression coverage for reserved tag characters, shared identifiers, and cyclic nested objects.
  • Define a scoped cache-pool or namespace cutover for existing entries using the old tag format. Do not flush a shared Redis database.
  • Verify nested-request behavior in a consuming application.
  • Add coverage for cache-key invalidation when manual tag definitions change.

@sidux
sidux requested review from Shivoham and kletord July 8, 2024 10:33
@sidux
sidux force-pushed the improve-cache-invalidation branch 2 times, most recently from 1df0ed1 to 3dfa67f Compare July 8, 2024 12:27
@sidux
sidux force-pushed the improve-cache-invalidation branch from 3dfa67f to 4d8df97 Compare July 8, 2024 12:56
@sidux
sidux force-pushed the improve-cache-invalidation branch 3 times, most recently from 1f0a28c to b8729a3 Compare July 8, 2024 14:55
@github-actions

github-actions Bot commented Jul 8, 2024

Copy link
Copy Markdown

Issued by Coverage Checker:

Comment thread src/Interceptor/Impl/CacheTagsTrait.php Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

needs tests

Comment thread src/Interceptor/Impl/CacheTagsTrait.php Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

needs test

Comment thread src/Interceptor/Impl/CacheTagsTrait.php Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

needs test

Comment thread src/Interceptor/Impl/CacheTagsTrait.php Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

needs tests

Comment thread src/Interceptor/Impl/CacheTagsTrait.php Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

is there a possible embedded requests edge case ?

@sidux
sidux force-pushed the improve-cache-invalidation branch from b8729a3 to 2d77187 Compare July 8, 2024 15:10
sidux and others added 3 commits July 8, 2024 18:13
Merge current master and retain cache configuration and reserved-character handling.

Track visited objects to handle cycles and collect all tags from objects sharing identifiers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant