src/Files.php
/**
     * Saves data to the cache.
     *
     * @param  mixed $data The data to cache.
     * @param  string $key The cache id to save.
     * @param  array $tags The cache tags for this cache entry.
     * @param  int $ttl The time-to-live in seconds, if set to null the
     *                       cache is valid forever.
     * @return boolean Returns True on success or False on failure.
     */
Saves data to the cache.
@param  mixed $data The data to cache.
@param  string $key The cache id to save.
@param  array $tags The cache tags for this cache entry.
@param  int $ttl The time-to-live in seconds, if set to null the
cache is valid forever.
@return boolean Returns True on success or False on failure.
Saves data to the cache . @param mixed $data The data to cache . @param string $key The cache id to save . @param array $tags The cache tags for this cache entry . @param int $ttl The time - to - live in seconds if set to null the cache is valid forever . @return boolean Returns True on success or False on failure .
public function save($data, $key, array $tags = null, $ttl = null)
    {
        $key = $this->mapKey($key);
        $expire = (null === $ttl) ? 0 : time() + $ttl;
        $tag = '';
        if (null !== $tags) {
            $baseTags = $tags;
            array_walk($baseTags, function (&$item, $key, Files $cache) {
                $item = base64_encode($cache->mapTag($item));
            }, $this);
            $tag = implode(' ', $baseTags);
        }
        $path = $this->getOption('directory') . DIRECTORY_SEPARATOR . base64_encode($key);
        file_put_contents(
            $path,
            $tag . PHP_EOL . $expire . PHP_EOL . serialize($data),
            $this->getOption('locking') ? LOCK_EX : null
        );
        return true;
    }
public function save ( $ data , $ key , array $ tags = null , $ ttl = null ) { $ key = $ this -> mapKey ( $ key ) ; $ expire = ( null === $ ttl ) ? 0 : time ( ) + $ ttl ; $ tag = '' ; if ( null !== $ tags ) { $ baseTags = $ tags ; array_walk ( $ baseTags , function ( & $ item , $ key , Files $ cache ) { $ item = base64_encode ( $ cache -> mapTag ( $ item ) ) ; } , $ this ) ; $ tag = implode ( ' ' , $ baseTags ) ; } $ path = $ this -> getOption ( 'directory' ) . DIRECTORY_SEPARATOR . base64_encode ( $ key ) ; file_put_contents ( $ path , $ tag . PHP_EOL . $ expire . PHP_EOL . serialize ( $ data ) , $ this -> getOption ( 'locking' ) ? LOCK_EX : null ) ; return true ; }
Saves data to the cache.
Saves data to the cache .