Sulu\Component\Cache\MemoizeInterface::memoize PHP Method

memoize() public method

Returns the value stored in the cache or uses the passed function to compute the value and save to cache This function uses the callstack to generate a unique key for the caching mechanism.
public memoize ( callable $compute, integer $lifeTime = null ) : mixed
$compute callable
$lifeTime integer cache lifetime
return mixed
    public function memoize($compute, $lifeTime = null);

Usage Example

Beispiel #1
0
 /**
  * @return array
  */
 public function getTagsFunction()
 {
     return $this->memoizeCache->memoize(function () {
         $tags = $this->tagManager->findAll();
         $context = SerializationContext::create();
         $context->setSerializeNull(true);
         $context->setGroups(['partialTag']);
         return $this->serializer->serialize($tags, 'array', $context);
     });
 }
All Usage Examples Of Sulu\Component\Cache\MemoizeInterface::memoize
MemoizeInterface