We have multiple development-environments on one machine and make use of APCu. This resulted in cache key collisions because the keys aren't prefixed by default, so we had to implement our own "prefix strategy":
use Asm89\Twig\CacheExtension\CacheStrategy\IndexedChainingCacheStrategy;
/**
* Prefix the key while instantiating strategy with the Symfony kernel environment.
*/
class PrefixCacheStrategy extends IndexedChainingCacheStrategy
{
private $prefix;
public function generateKey($annotation, $value)
{
$annotation = $this->prefix . '_' . $annotation;
return parent::generateKey($annotation, $value);
}
public function setPrefix($prefix)
{
$this->prefix = $prefix;
}
}
I am not sure here, but I don't think this is a functionality which should be supported by default. Creating your own strategy for this special usecase seems ok to me.
We have multiple development-environments on one machine and make use of APCu. This resulted in cache key collisions because the keys aren't prefixed by default, so we had to implement our own "prefix strategy":
Service definition:
Given you also choose
IndexedChainingCacheStrategy
as a default, what about prefixing the keys with the Symfony kernel environment by default too?