function save($data, $id = NULL, $group = 'default')
    {
        if ($this->_caching) {
            if ($this->_automaticSerialization) {
                $data = serialize($data);
            }
            if (isset($id)) {
                $this->_setFileName($id, $group);
            }
            if ($this->_memoryCaching) {
                $this->_memoryCacheAdd($data);
                if ($this->_onlyMemoryCaching) {
                    return true;
                }
            }
            if ($this->_automaticCleaningFactor>0 && ($this->_automaticCleaningFactor==1 || mt_rand(1, $this->_automaticCleaningFactor)==1)) {
				$this->clean(false, 'old');			
			}
            if ($this->_writeControl) {
                $res = $this->_writeAndControl($data);
                if (is_bool($res)) {
                    if ($res) {
                        return true;  
                    }
                    // if $res if false, we need to invalidate the cache
                    @touch($this->_file, time() - 2*abs($this->_lifeTime));
                    return false;
                }            
            } else {
                $res = $this->_write($data);
            }
            if (is_object($res)) {
                // $res is a PEAR_Error object 
                if (!($this->_errorHandlingAPIBreak)) {   
                    return false; // we return false (old API)
                }
            }
            return $res;
        }
        return false;
    }
function save($data, $id = NULL, $group = 'default')
    {
        if ($this->_caching) {
            if ($this->_automaticSerialization) {
                $data = serialize($data);
            }
            if (isset($id)) {
                $this->_setFileName($id, $group);
            }
            if ($this->_memoryCaching) {
                $this->_memoryCacheAdd($data);
                if ($this->_onlyMemoryCaching) {
                    return true;
                }
            }
            if ($this->_automaticCleaningFactor>0 && ($this->_automaticCleaningFactor==1 || mt_rand(1, $this->_automaticCleaningFactor)==1)) {
				$this->clean(false, 'old');			
			}
            if ($this->_writeControl) {
                $res = $this->_writeAndControl($data);
                if (is_bool($res)) {
                    if ($res) {
                        return true;  
                    }
                    // if $res if false, we need to invalidate the cache
                    @touch($this->_file, time() - 2*abs($this->_lifeTime));
                    return false;
                }            
            } else {
                $res = $this->_write($data);
            }
            if (is_object($res)) {
                // $res is a PEAR_Error object 
                if (!($this->_errorHandlingAPIBreak)) {   
                    return false; // we return false (old API)
                }
            }
            return $res;
        }
        return false;
    }
function save ( $ data , $ id = NULL , $ group = 'default' ) { if ( $ this -> _caching ) { if ( $ this -> _automaticSerialization ) { $ data = serialize ( $ data ) ; } if ( isset ( $ id ) ) { $ this -> _setFileName ( $ id , $ group ) ; } if ( $ this -> _memoryCaching ) { $ this -> _memoryCacheAdd ( $ data ) ; if ( $ this -> _onlyMemoryCaching ) { return true ; } } if ( $ this -> _automaticCleaningFactor > 0 && ( $ this -> _automaticCleaningFactor == 1 || mt_rand ( 1 , $ this -> _automaticCleaningFactor ) == 1 ) ) { $ this -> clean ( false , 'old' ) ; } if ( $ this -> _writeControl ) { $ res = $ this -> _writeAndControl ( $ data ) ; if ( is_bool ( $ res ) ) { if ( $ res ) { return true ; } // if $res if false, we need to invalidate the cache @ touch ( $ this -> _file , time ( ) - 2 * abs ( $ this -> _lifeTime ) ) ; return false ; } } else { $ res = $ this -> _write ( $ data ) ; } if ( is_object ( $ res ) ) { // $res is a PEAR_Error object  if ( ! ( $ this -> _errorHandlingAPIBreak ) ) { return false ; // we return false (old API) } } return $ res ; } return false ; }
Save some data in a cache file

@param string $data data to put in cache (can be another type than strings if automaticSerialization is on)
@param string $id cache id
@param string $group name of the cache group
@return boolean true if no problem (else : false or a PEAR_Error object)
@access public
Save some data in a cache file