Object/facade/CacheManager.php
protected function callClosure(\Closure $closure, $closureArguments, $id, $key)
    {
        $result = call_user_func_array($closure, $closureArguments);
        
        $cacheCollection = $this->getProvider()->get($id);
        if ($cacheCollection === null) {
            $cacheCollection = new CacheCollection($id);
        }
        
        if ($cacheCollection->has($key)) {
            $cacheCollection->get($key)->setContent($result);
        } else {
            $cacheCollection->create($key, $result);
        }
        
        try{
            $this->getProvider()->save($cacheCollection);
        } catch (\Exception $e) {
            throw new \Exception(sprintf("The closure must return a string value to be stored into the cache. %s returned", gettype($result)), 500);
        }
        
        return $result;
    }
protected function callClosure(\Closure $closure, $closureArguments, $id, $key)
    {
        $result = call_user_func_array($closure, $closureArguments);
        
        $cacheCollection = $this->getProvider()->get($id);
        if ($cacheCollection === null) {
            $cacheCollection = new CacheCollection($id);
        }
        
        if ($cacheCollection->has($key)) {
            $cacheCollection->get($key)->setContent($result);
        } else {
            $cacheCollection->create($key, $result);
        }
        
        try{
            $this->getProvider()->save($cacheCollection);
        } catch (\Exception $e) {
            throw new \Exception(sprintf("The closure must return a string value to be stored into the cache. %s returned", gettype($result)), 500);
        }
        
        return $result;
    }
Call closure

Call the given closure
and register the result
in cache

@param \Closure $closure          - the closure
@param array    $closureArguments - the closure arguments
@param string   $id               - the cache id
@param string   $key              - the cache key

@return string - the result of the closure
@throws \Exception - throw an exception if the result of the closure is not a string