public function put($key, $item)
    {
        $file = $this->filename($key);

        // json
        // text
        if (!file_put_contents($file, serialize($item))) {
            throw new \Exception(
                t("Failed writing cache object '!key'.", [
                    '!key' => $key
                ])
            );
        }
    }
public function put($key, $item)
    {
        $file = $this->filename($key);

        // json
        // text
        if (!file_put_contents($file, serialize($item))) {
            throw new \Exception(
                t("Failed writing cache object '!key'.", [
                    '!key' => $key
                ])
            );
        }
    }
public function put ( $ key , $ item ) { $ file = $ this -> filename ( $ key ) ; // json // text if ( ! file_put_contents ( $ file , serialize ( $ item ) ) ) { throw new \ Exception ( t ( "Failed writing cache object '!key'." , [ '!key' => $ key ] ) ) ; } }
Put an item to the cache.

@param string $key  to the cached object.
@param mixed  $item the object to be cached.

@throws Exception if failing to write to cache.

@return void
Put an item to the cache .