class FilesystemCache in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/doctrine/cache/lib/Doctrine/Common/Cache/FilesystemCache.php \Doctrine\Common\Cache\FilesystemCache
Filesystem 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\FilesystemCache
- class \Doctrine\Common\Cache\FileCache
Expanded class hierarchy of FilesystemCache
1 file declares its use of FilesystemCache
- FilesystemCacheTest.php in vendor/
doctrine/ cache/ tests/ Doctrine/ Tests/ Common/ Cache/ FilesystemCacheTest.php
File
- vendor/
doctrine/ cache/ lib/ Doctrine/ Common/ Cache/ FilesystemCache.php, line 28
Namespace
Doctrine\Common\CacheView source
class FilesystemCache extends FileCache {
const EXTENSION = '.doctrinecache.data';
/**
* {@inheritdoc}
*/
public function __construct($directory, $extension = self::EXTENSION, $umask = 02) {
parent::__construct($directory, $extension, $umask);
}
/**
* {@inheritdoc}
*/
protected function doFetch($id) {
$data = '';
$lifetime = -1;
$filename = $this
->getFilename($id);
if (!is_file($filename)) {
return false;
}
$resource = fopen($filename, "r");
if (false !== ($line = fgets($resource))) {
$lifetime = (int) $line;
}
if ($lifetime !== 0 && $lifetime < time()) {
fclose($resource);
return false;
}
while (false !== ($line = fgets($resource))) {
$data .= $line;
}
fclose($resource);
return unserialize($data);
}
/**
* {@inheritdoc}
*/
protected function doContains($id) {
$lifetime = -1;
$filename = $this
->getFilename($id);
if (!is_file($filename)) {
return false;
}
$resource = fopen($filename, "r");
if (false !== ($line = fgets($resource))) {
$lifetime = (int) $line;
}
fclose($resource);
return $lifetime === 0 || $lifetime > time();
}
/**
* {@inheritdoc}
*/
protected function doSave($id, $data, $lifeTime = 0) {
if ($lifeTime > 0) {
$lifeTime = time() + $lifeTime;
}
$data = serialize($data);
$filename = $this
->getFilename($id);
return $this
->writeFile($filename, $lifeTime . PHP_EOL . $data);
}
}
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. | |
FilesystemCache:: |
protected | function |
Tests if an entry exists in the cache. Overrides CacheProvider:: |
|
FilesystemCache:: |
protected | function |
Fetches an entry from the cache. Overrides CacheProvider:: |
|
FilesystemCache:: |
protected | function |
Puts data into the cache. Overrides CacheProvider:: |
|
FilesystemCache:: |
constant | |||
FilesystemCache:: |
public | function |
Constructor. Overrides FileCache:: |