/** * @return bool */ public function touch() { if (!IOHelper::touch($this->getRealPath())) { return false; } return true; }
/** * Stores a value identified by a key in cache. This is the implementation of the method declared in the parent class. * * @param string $key The key identifying the value to be cached * @param string $value The value to be cached * @param integer $expire The number of seconds in which the cached value will expire. 0 means never expire. * @return boolean true If the value is successfully stored into cache, false otherwise */ protected function setValue($key, $value, $expire) { if (!$this->_gced && mt_rand(0, 1000000) < $this->getGCProbability()) { $this->gc(); $this->_gced = true; } if ($expire <= 0) { $expire = 31536000; // 1 year } $expire += time(); $cacheFile = $this->getCacheFile($key); if ($this->directoryLevel > 0) { IOHelper::createFolder(IOHelper::getFolderName($cacheFile), IOHelper::getWritableFolderPermissions()); } if ($this->_originalKey == 'useWriteFileLock') { if (IOHelper::writeToFile($cacheFile, $value, true, false, true) !== false) { IOHelper::changePermissions($cacheFile, IOHelper::getWritableFilePermissions()); return IOHelper::touch($cacheFile, $expire); } else { return false; } } else { if (IOHelper::writeToFile($cacheFile, $value) !== false) { IOHelper::changePermissions($cacheFile, IOHelper::getWritableFilePermissions()); return IOHelper::touch($cacheFile, $expire); } else { return false; } } }