Skip to content
Permalink
Browse files

fix caching of substitutions in cached masks

  • Loading branch information...
tsurowiec committed Nov 7, 2018
1 parent bd3da17 commit f1fc5b9d0bce53302dd73c717ff68971314b0132
Showing with 5 additions and 3 deletions.
  1. +5 −3 src/Fogger/Mask/AbstractCachedMask.php
@@ -20,9 +20,11 @@ public function __construct(CacheItemPoolInterface $cache)
abstract protected function getSubstitution(array $options = []): ?string;
private function forgeCacheKey(string $value, array $options)
private function forgeCacheKey(string $value, array $options, bool $substitute = false)
{
return md5(sprintf("%s.%s.%s", $value, $this->getMaskName(), json_encode($options)));
return md5(
sprintf("%s.%s.%s.%s", $value, $this->getMaskName(), json_encode($options), $substitute)
);
}
/**
@@ -50,7 +52,7 @@ public function apply(?string $value, array $options = []): ?string
do {
$substitution = $this->getSubstitution($options);
$substitutionCacheItem = $this->cache->getItem($this->forgeCacheKey($substitution, $options));
$substitutionCacheItem = $this->cache->getItem($this->forgeCacheKey($substitution, $options, true));
} while ($substitutionCacheItem->isHit());
$this->cache->save($substitutionCacheItem);

0 comments on commit f1fc5b9

Please sign in to comment.
You can’t perform that action at this time.