Skip to content

Commit f6cc5e9

Browse files
committed
docs: Add docblocks to interceptor classes
- Document which attributes each interceptor binds to - Clarify CQRS query (onGet) vs command (onPut/onPatch/onDelete) distinction - Add links to attribute classes and manual sections - Explain cache behavior and ETag generation differences Interceptors documented: - CacheInterceptor: TTL-based caching for queries - CommandInterceptor: Cache invalidation for commands - HttpCacheInterceptor: HTTP Cache-Control header - DonutCacheInterceptor: Donut caching for queries - DonutCacheableResponseInterceptor: Full response caching for queries - DonutCommandInterceptor: Donut cache invalidation for commands - RefreshInterceptor: Cache refresh for non-Cacheable classes
1 parent 18b5578 commit f6cc5e9

7 files changed

Lines changed: 70 additions & 0 deletions

src/CacheInterceptor.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@
1717

1818
use const E_USER_WARNING;
1919

20+
/**
21+
* Interceptor for TTL-based caching on CQRS queries with #[Cacheable]
22+
*
23+
* Bound to query methods (onGet) of classes marked with #[Cacheable].
24+
* Retrieves cached resource state if available, otherwise executes
25+
* the method and stores the result with configured TTL.
26+
*
27+
* @see \BEAR\RepositoryModule\Annotation\Cacheable
28+
* @see https://bearsunday.github.io/manuals/1.0/en/cache.html#cacheable
29+
*/
2030
final readonly class CacheInterceptor implements MethodInterceptor
2131
{
2232
public function __construct(

src/CommandInterceptor.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@
1212
use Ray\Aop\MethodInterceptor;
1313
use Ray\Aop\MethodInvocation;
1414

15+
/**
16+
* Interceptor for cache invalidation on CQRS commands with #[Purge] or #[Refresh]
17+
*
18+
* Bound to command methods (onPut/onPatch/onDelete) of #[Cacheable] classes.
19+
* Executes cache invalidation after successful write operations.
20+
*
21+
* @see \BEAR\RepositoryModule\Annotation\Purge
22+
* @see \BEAR\RepositoryModule\Annotation\Refresh
23+
* @see https://bearsunday.github.io/manuals/1.0/en/cache.html#tag-based-cache-invalidation
24+
*/
1525
final readonly class CommandInterceptor implements MethodInterceptor
1626
{
1727
/** @param CommandInterface[] $commands */

src/DonutCacheInterceptor.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@
44

55
namespace BEAR\QueryRepository;
66

7+
/**
8+
* Interceptor for donut caching on CQRS queries with #[DonutCache]
9+
*
10+
* Bound to query methods (onGet) or individual methods marked with #[DonutCache].
11+
* Caches only the cacheable portions, excluding non-cacheable embedded content.
12+
* No ETag is generated for the entire response.
13+
*
14+
* @see \BEAR\RepositoryModule\Annotation\DonutCache
15+
* @see https://bearsunday.github.io/manuals/1.0/en/cache.html#donut-cache
16+
*/
717
final class DonutCacheInterceptor extends AbstractDonutCacheInterceptor
818
{
919
protected const IS_ENTIRE_CONTENT_CACHEABLE = false;

src/DonutCacheableResponseInterceptor.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@
44

55
namespace BEAR\QueryRepository;
66

7+
/**
8+
* Interceptor for full response caching on CQRS queries with #[CacheableResponse]
9+
*
10+
* Bound to query methods (onGet) of classes marked with #[CacheableResponse].
11+
* Caches the entire response and generates an ETag for conditional requests.
12+
* Enables 304 (Not Modified) responses for efficient network transfer.
13+
*
14+
* @see \BEAR\RepositoryModule\Annotation\CacheableResponse
15+
* @see https://bearsunday.github.io/manuals/1.0/en/cache.html#event-driven-content
16+
*/
717
final class DonutCacheableResponseInterceptor extends AbstractDonutCacheInterceptor
818
{
919
protected const IS_ENTIRE_CONTENT_CACHEABLE = true;

src/DonutCommandInterceptor.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@
1919
use function is_callable;
2020
use function sprintf;
2121

22+
/**
23+
* Interceptor for donut cache invalidation on CQRS commands
24+
*
25+
* Bound to command methods (onPut/onPatch/onDelete) of classes marked with #[CacheableResponse].
26+
* Refreshes donut cache and resource state after successful write operations.
27+
*
28+
* @see \BEAR\RepositoryModule\Annotation\CacheableResponse
29+
* @see \BEAR\RepositoryModule\Annotation\DonutCache
30+
* @see https://bearsunday.github.io/manuals/1.0/en/cache.html#event-driven-content
31+
*/
2232
final readonly class DonutCommandInterceptor implements MethodInterceptor
2333
{
2434
public function __construct(

src/HttpCacheInterceptor.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@
1414

1515
use function assert;
1616

17+
/**
18+
* Interceptor for HTTP Cache-Control header with #[HttpCache] or #[NoHttpCache]
19+
*
20+
* Bound to onGet methods of classes marked with #[HttpCache] or #[NoHttpCache].
21+
* Sets the Cache-Control header based on attribute configuration for HTTP caching.
22+
*
23+
* @see \BEAR\RepositoryModule\Annotation\HttpCache
24+
* @see \BEAR\RepositoryModule\Annotation\NoHttpCache
25+
* @see https://bearsunday.github.io/manuals/1.0/en/cache.html
26+
*/
1727
final class HttpCacheInterceptor implements MethodInterceptor
1828
{
1929
/**

src/RefreshInterceptor.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@
1111
use Ray\Aop\MethodInterceptor;
1212
use Ray\Aop\MethodInvocation;
1313

14+
/**
15+
* Interceptor for cache refresh commands with #[Purge] or #[Refresh]
16+
*
17+
* Bound to methods marked with #[Purge] or #[Refresh] on non-Cacheable classes.
18+
* Executes cache invalidation commands after successful method execution.
19+
*
20+
* @see \BEAR\RepositoryModule\Annotation\Purge
21+
* @see \BEAR\RepositoryModule\Annotation\Refresh
22+
* @see https://bearsunday.github.io/manuals/1.0/en/cache.html#event-driven-content
23+
*/
1424
final readonly class RefreshInterceptor implements MethodInterceptor
1525
{
1626
public function __construct(

0 commit comments

Comments
 (0)