src/cache/File.php
public function set($id, $data, $lifetime = NULL) {
        if ($lifetime === NULL) {
            $lifetime = $this->default_expire;
        }

        $filename = $this->cache_file($id);

        if ($this->directory_level > 0) {
            FS::mkdir(dirname($filename), $this->chmode);
        }
        if (@file_put_contents($filename, serialize($data), LOCK_EX) !== false) {
            if ($this->chmode !== null) {
                @chmod($filename, $this->chmode);
            }
            if ($lifetime <= 0) {
                $lifetime = 60*60*24*7;
            }
            return @touch($filename, $lifetime + time());
        }
        $error = error_get_last();

        \Mii::warning("Unable to write cache file '{$filename}': {$error['message']}", 'mii');
        return false;

    }
public function set($id, $data, $lifetime = NULL) {
        if ($lifetime === NULL) {
            $lifetime = $this->default_expire;
        }

        $filename = $this->cache_file($id);

        if ($this->directory_level > 0) {
            FS::mkdir(dirname($filename), $this->chmode);
        }
        if (@file_put_contents($filename, serialize($data), LOCK_EX) !== false) {
            if ($this->chmode !== null) {
                @chmod($filename, $this->chmode);
            }
            if ($lifetime <= 0) {
                $lifetime = 60*60*24*7;
            }
            return @touch($filename, $lifetime + time());
        }
        $error = error_get_last();

        \Mii::warning("Unable to write cache file '{$filename}': {$error['message']}", 'mii');
        return false;

    }
Set a value to cache with id and lifetime

$data = 'bar';

// Set 'bar' to 'foo' in apc group, using default expiry
Cache::instance('apc')->set('foo', $data);

// Set 'bar' to 'foo' in apc group for 30 seconds
Cache::instance('apc')->set('foo', $data, 30);

@param   string $id id of cache entry
@param   string $data data to set to cache
@param   integer $lifetime lifetime in seconds
@return  boolean