Prado\I18N\core\TCache_Lite::save PHP Метод

save() публичный Метод

Save some data in a cache file
public save ( string $data, string $id = null, string $group = 'default' ) : boolean
$data string data to put in cache (can be another type than strings if automaticSerialization is on)
$id string cache id
$group string name of the cache group
Результат boolean true if no problem
    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($this->_file, $data);
                if ($this->_onlyMemoryCaching) {
                    return true;
                }
            }
            if ($this->_writeControl) {
                if (!$this->_writeAndControl($data)) {
                    @touch($this->_file, time() - 2 * abs($this->_lifeTime));
                    return false;
                } else {
                    return true;
                }
            } else {
                return $this->_write($data);
            }
        }
        return false;
    }

Usage Example

Пример #1
0
 /**
  * Save the data to cache for the specified section and locale.
  * @param array $data The data to save.
  * @param string $catalogue The translation section.
  * @param string $culture The translation locale, e.g. "en_AU".
  */
 public function save($data, $catalogue, $culture)
 {
     $ID = $this->getID($catalogue, $culture);
     $group = $this->getGroup($catalogue, $culture);
     //echo '## Cache save: "'.$ID.'" : "'.$group.'"';
     //echo "<br>\n";
     return $this->cache->save($data, $ID, $group);
 }