- Added caching mechanism as an event listener

This commit is contained in:
Dave Mc Nicoll committed 2024-12-02 15:22:30 -05:00
1 parent b601939459
commit 9eed2fe1a8
25 files changed
+607 -402

No files matched your search

+22
View File
@@ -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));
}
}
}