private function addCache($policy, $cache, $value, $duration) {
        $content = is_callable($value) ? $value() : $value;

        $policyContent = json_encode(array('absoluteExpiration' => $duration > 0 ? time() + $duration : 0));

        if ($this->tryWriteFile($policy, $policyContent) === true) {
            if (!$this->tryWriteFile($cache, serialize($content))) {
                $this->tryDeleteFile($policy);
            }
        }

        return $content;
    }