- Added caching mechanism as an event listener
This commit is contained in:
1 parent
b601939459
commit
9eed2fe1a8
25 files changed
+607
-402
No files matched your search
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Ulmus\Cache;
|
||||
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
|
||||
trait CacheEventTrait
|
||||
{
|
||||
public function __construct(
|
||||
protected CacheInterface $cache,
|
||||
protected string $cacheKey,
|
||||
) {}
|
||||
|
||||
public function purgeCache() : void
|
||||
{
|
||||
$keys = $this->cache->get($this->cacheKey);
|
||||
|
||||
if ( $keys && is_iterable($keys) ) {
|
||||
$this->cache->deleteMultiple(array_map(fn($e) => sprintf("%s:%s:", $this->cacheKey, $e), $keys));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user