Source for file trifile.php
Documentation is available at trifile.php
// +----------------------------------------------------------------------+
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Ulf Wendel <ulf.wendel@phpdoc.de> |
// | Sebastian Bergmann <sb@sebastian-bergmann.de> |
// | Ian Eure <ieure@php.net> |
// +----------------------------------------------------------------------+
// $Id: trifile.php,v 1.5 2005/04/18 19:05:01 dufuz Exp $
require_once 'Cache/Container/file.php';
* This cache container stores files with no special encoding to reduce overhead.
* Expiration & user data are stored in seperate files, prefixed with a '.' and
* suffixed with '.exp' & '.dat' respectively.
* See http://atomized.org/PEAR/Cache_trifile.html for more information.
* @author Ian Eure <ieure@php.net>
* @param string $id Cache ID to fetch
* @param string $group Group to fetch from
* @return array 1-dimensional array in the format: expiration,data,userdata
function fetch($id, $group)
if (PEAR ::isError ($file)) {
return array (null , null , null );
* Get the file to store cache data in.
* @return string Cache data file name
* Get the file to store expiration data in.
* @return string Expiration data file name
function _getExpFile ($file)
return $this->_getFile ($file). '.exp';
* Get the file to store user data in.
* @return string User data file name
function _getUDFile ($file)
return $this->_getFile ($file). '.dat';
* @param string $id Cache ID
* @param mixed $cachedata Data to cache
* @param mixed $expires When the data expires
* @param string $group Cache group to store data in
* @param mixed $userdata Additional data to store
* @return boolean true on success, false otherwise
function save($id, $cachedata, $expires, $group, $userdata)
if (PEAR ::isError ($file)) {
if (PEAR ::isError ($res = $this->_saveData ($file, $cachedata))) {
if (PEAR ::isError ($res = $this->_saveData ($this->_getExpFile ($file), $expires))) {
if (PEAR ::isError ($res = $this->_saveData ($this->_getUDFile ($file), $userdata))) {
* @param string $file File to save data in
* @param string $data Data to save
* @return mixed true on success, Cache_Error otherwise
function _saveData ($file, $data)
if (!($fh = @fopen($file, 'wb')))
return new Cache_Error(" Can't access '$file' to store cache data. Check access rights and path." , __FILE__ , __LINE__ );
Documentation generated on Mon, 11 Mar 2019 15:25:51 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|