CachingDecorator
- Full name:
\Codefy\CommandBus\Decorators\CachingDecorator
- This class implements:
\Codefy\CommandBus\Decorator
Properties
cache
expiresAfter
innerBus
Methods
__construct
public __construct(\Psr\Cache\CacheItemPoolInterface $cache, int $expiresAfter, \Codefy\CommandBus\CommandBus $innerBus): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$cache | \Psr\Cache\CacheItemPoolInterface | |
$expiresAfter | int | |
$innerBus | \Codefy\CommandBus\CommandBus |
setInnerBus
Set the CommandBus which we're decorating.
Parameters:
Parameter | Type | Description |
---|---|---|
$bus | \Codefy\CommandBus\CommandBus |
execute
Execute a command
Parameters:
Parameter | Type | Description |
---|---|---|
$command | \Codefy\CommandBus\Command |
Throws:
createCacheItem
Create a new cache item to be persisted.
private createCacheItem(\Codefy\CommandBus\CacheableCommand $command, mixed $value): \Psr\Cache\CacheItemInterface
Parameters:
Parameter | Type | Description |
---|---|---|
$command | \Codefy\CommandBus\CacheableCommand | |
$value | mixed |
Throws:
getCacheKey
Create the key to be used when saving this item to the cache pool.
The cache item key is taken as a (string) serialized command, to ensure the return value is unique depending on the command properties; that serialized string is then md5'd to ensure it doesn't overflow any string length limits the implementing CacheItemPoolInterface library has.
Parameters:
Parameter | Type | Description |
---|---|---|
$command | \Codefy\CommandBus\CacheableCommand |
getCacheExpiry
Determine when this CachableCommand should expire, in terms of seconds from now.
Parameters:
Parameter | Type | Description |
---|---|---|
$command | \Codefy\CommandBus\CacheableCommand |
Automatically generated on 2025-10-13