本文整理汇总了PHP中Thin\File::get方法的典型用法代码示例。如果您正苦于以下问题:PHP File::get方法的具体用法?PHP File::get怎么用?PHP File::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Thin\File
的用法示例。
在下文中一共展示了File::get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* Get the contents of a file.
*
* @param string $path
* @return string
*
* @throws Exception
*/
public function get($path)
{
if ($this->isFile($path)) {
return File::get($path);
}
throw new Exception("File does not exist at path {$path}");
}
示例2: cached
private function cached($key, $value = null)
{
if (false === $this->cache) {
return null;
}
$settings = isAke(self::$configs, $this->entity);
$event = isAke($settings, 'cache');
if (!empty($event)) {
return $this->{$event}($key, $value);
}
$file = STORAGE_PATH . DS . 'cache' . DS . $key . '.eav';
if (empty($value)) {
if (File::exists($file)) {
$age = filemtime($file);
$maxAge = time() - $this->ttl;
if ($maxAge < $age) {
return json_decode(File::get($file), true);
} else {
File::delete($file);
return null;
}
}
} else {
if (File::exists($file)) {
File::delete($file);
}
File::put($file, json_encode($value));
return true;
}
}
示例3: cache
public static function cache($type, $key, $data = null)
{
$settings = Arrays::exists($type, static::$_settings) ? static::$_settings[$type] : static::defaultConfig($type);
$hook = Arrays::exists('cache', $settings) ? $settings['cache'] : null;
static::_hook($hook, func_get_args(), 'before');
$dir = static::checkDir($type);
$file = STORAGE_PATH . DS . 'data' . DS . $dir . DS . $key . '.cache';
if (File::exists($file)) {
static::_hook($hook, func_get_args(), 'after');
return static::unserialize(gzuncompress(File::get($file)));
}
if (null !== $data) {
File::put($file, gzcompress(static::serialize($data), -1));
static::_hook($hook, func_get_args(), 'after');
return true;
}
static::_hook($hook, func_get_args(), 'after');
return null;
}