class PhpFileCache in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/doctrine/cache/lib/Doctrine/Common/Cache/PhpFileCache.php \Doctrine\Common\Cache\PhpFileCache
Php file cache driver.
@since 2.3 @author Fabio B. Silva <fabio.bat.silva@gmail.com>
Hierarchy
- class \Doctrine\Common\Cache\CacheProvider implements Cache, ClearableCache, FlushableCache, MultiGetCache
- class \Doctrine\Common\Cache\FileCache
- class \Doctrine\Common\Cache\PhpFileCache
- class \Doctrine\Common\Cache\FileCache
Expanded class hierarchy of PhpFileCache
1 file declares its use of PhpFileCache
- PhpFileCacheTest.php in vendor/
doctrine/ cache/ tests/ Doctrine/ Tests/ Common/ Cache/ PhpFileCacheTest.php
File
- vendor/
doctrine/ cache/ lib/ Doctrine/ Common/ Cache/ PhpFileCache.php, line 28
Namespace
Doctrine\Common\CacheView source
class PhpFileCache extends FileCache {
const EXTENSION = '.doctrinecache.php';
/**
* {@inheritdoc}
*/
public function __construct($directory, $extension = self::EXTENSION, $umask = 02) {
parent::__construct($directory, $extension, $umask);
}
/**
* {@inheritdoc}
*/
protected function doFetch($id) {
$value = $this
->includeFileForId($id);
if (!$value) {
return false;
}
if ($value['lifetime'] !== 0 && $value['lifetime'] < time()) {
return false;
}
return $value['data'];
}
/**
* {@inheritdoc}
*/
protected function doContains($id) {
$value = $this
->includeFileForId($id);
if (!$value) {
return false;
}
return $value['lifetime'] === 0 || $value['lifetime'] > time();
}
/**
* {@inheritdoc}
*/
protected function doSave($id, $data, $lifeTime = 0) {
if ($lifeTime > 0) {
$lifeTime = time() + $lifeTime;
}
if (is_object($data) && !method_exists($data, '__set_state')) {
throw new \InvalidArgumentException("Invalid argument given, PhpFileCache only allows objects that implement __set_state() " . "and fully support var_export(). You can use the FilesystemCache to save arbitrary object " . "graphs using serialize()/deserialize().");
}
$filename = $this
->getFilename($id);
$value = array(
'lifetime' => $lifeTime,
'data' => $data,
);
$value = var_export($value, true);
$code = sprintf('<?php return %s;', $value);
return $this
->writeFile($filename, $code);
}
/**
* @param string $id
*
* @return array|false
*/
private function includeFileForId($id) {
$fileName = $this
->getFilename($id);
// note: error suppression is still faster than `file_exists`, `is_file` and `is_readable`
$value = @(include $fileName);
if (!isset($value['lifetime'])) {
return false;
}
return $value;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Cache:: |
constant | |||
Cache:: |
constant | |||
Cache:: |
constant | Only for backward compatibility (may be removed in next major release) | ||
Cache:: |
constant | |||
Cache:: |
constant | |||
Cache:: |
constant | |||
CacheProvider:: |
private | property | The namespace to prefix all cache ids with. | |
CacheProvider:: |
private | property | The namespace version. | |
CacheProvider:: |
public | function |
Tests if an entry exists in the cache. Overrides Cache:: |
|
CacheProvider:: |
public | function |
Deletes a cache entry. Overrides Cache:: |
|
CacheProvider:: |
public | function |
Deletes all cache entries in the current cache namespace. Overrides ClearableCache:: |
|
CacheProvider:: |
constant | |||
CacheProvider:: |
protected | function | Default implementation of doFetchMultiple. Each driver that supports multi-get should owerwrite it. | 4 |
CacheProvider:: |
public | function |
Fetches an entry from the cache. Overrides Cache:: |
|
CacheProvider:: |
public | function |
Returns an associative array of values for keys is found in cache. Overrides MultiGetCache:: |
|
CacheProvider:: |
public | function |
Flushes all cache entries, globally. Overrides FlushableCache:: |
|
CacheProvider:: |
public | function | Retrieves the namespace that prefixes all cache ids. | |
CacheProvider:: |
private | function | Returns the namespace cache key. | |
CacheProvider:: |
private | function | Prefixes the passed id with the configured namespace value. | |
CacheProvider:: |
private | function | Returns the namespace version. | |
CacheProvider:: |
public | function |
Retrieves cached information from the data store. Overrides Cache:: |
|
CacheProvider:: |
public | function |
Puts data into the cache. Overrides Cache:: |
|
CacheProvider:: |
public | function | Sets the namespace to prefix all cache ids with. | 1 |
FileCache:: |
protected | property | The cache directory. | |
FileCache:: |
private | property | ||
FileCache:: |
private | property | The cache file extension. | |
FileCache:: |
private | property | ||
FileCache:: |
private | property | ||
FileCache:: |
private | function | Create path if needed. | |
FileCache:: |
protected | function |
Deletes a cache entry. Overrides CacheProvider:: |
|
FileCache:: |
protected | function |
Flushes all cache entries. Overrides CacheProvider:: |
|
FileCache:: |
protected | function |
Retrieves cached information from the data store. Overrides CacheProvider:: |
|
FileCache:: |
public | function | Gets the cache directory. | |
FileCache:: |
public | function | Gets the cache file extension. | |
FileCache:: |
protected | function | ||
FileCache:: |
private | function | ||
FileCache:: |
protected | function | Writes a string content to file in an atomic way. | |
PhpFileCache:: |
protected | function |
Tests if an entry exists in the cache. Overrides CacheProvider:: |
|
PhpFileCache:: |
protected | function |
Fetches an entry from the cache. Overrides CacheProvider:: |
|
PhpFileCache:: |
protected | function |
Puts data into the cache. Overrides CacheProvider:: |
|
PhpFileCache:: |
constant | |||
PhpFileCache:: |
private | function | ||
PhpFileCache:: |
public | function |
Constructor. Overrides FileCache:: |