Slide 70
Slide 70 text
class CachingAspect implements Aspect
{
/**
* @Around("execution(public SecretService->getSecret(*))")
*/
public function cacheGetSecret(MethodInvocation $invocation)
{
$args = $invocation->getArguments();
if ($this->cache->has($args[0])) {
return $this->cache->get($args[0]);
}
$secret = $invocation->proceed();
$this->cache->set($args[0], $secret);
return $secret;
}
}