PhpFileCache
extends FileCache
in package
Php file cache driver.
Tags
Table of Contents
- DOCTRINE_NAMESPACE_CACHEKEY = 'DoctrineNamespaceCacheKey[%s]'
- EXTENSION = '.doctrinecache.php'
- $directory : string
- The cache directory.
- $directoryStringLength : int
- $extension : string
- The cache file extension.
- $extensionStringLength : int
- $isRunningOnWindows : bool
- $namespace : string
- The namespace to prefix all cache ids with.
- $namespaceVersion : int|null
- The namespace version.
- $umask : int
- __construct() : mixed
- Constructor.
- contains() : bool
- Tests if an entry exists in the cache.
- delete() : bool
- Deletes a cache entry.
- deleteAll() : bool
- Deletes all cache entries in the current cache namespace.
- fetch() : mixed
- Fetches an entry from the cache.
- fetchMultiple() : array<string|int, mixed>
- Returns an associative array of values for keys is found in cache.
- flushAll() : bool
- Flushes all cache entries, globally.
- getDirectory() : string
- Gets the cache directory.
- getExtension() : string
- Gets the cache file extension.
- getNamespace() : string
- Retrieves the namespace that prefixes all cache ids.
- getStats() : array<string|int, mixed>|null
- Retrieves cached information from the data store.
- save() : bool
- Puts data into the cache.
- saveMultiple() : bool
- Returns a boolean value indicating if the operation succeeded.
- setNamespace() : void
- Sets the namespace to prefix all cache ids with.
- doContains() : mixed
- {@inheritdoc}
- doDelete() : bool
- Deletes a cache entry.
- doFetch() : mixed
- {@inheritdoc}
- doFetchMultiple() : array<string|int, mixed>
- Default implementation of doFetchMultiple. Each driver that supports multi-get should owerwrite it.
- doFlush() : bool
- Flushes all cache entries.
- doGetStats() : array<string|int, mixed>|null
- Retrieves cached information from the data store.
- doSave() : mixed
- {@inheritdoc}
- doSaveMultiple() : bool
- Default implementation of doSaveMultiple. Each driver that supports multi-put should override it.
- getFilename() : string
- writeFile() : bool
- Writes a string content to file in an atomic way.
- createPathIfNeeded() : bool
- Create path if needed.
- getIterator() : Iterator
- getNamespaceCacheKey() : string
- Returns the namespace cache key.
- getNamespacedId() : string
- Prefixes the passed id with the configured namespace value.
- getNamespaceVersion() : int
- Returns the namespace version.
- includeFileForId() : array<string|int, mixed>|false
- isFilenameEndingWithExtension() : bool
Constants
DOCTRINE_NAMESPACE_CACHEKEY
public
mixed
DOCTRINE_NAMESPACE_CACHEKEY
= 'DoctrineNamespaceCacheKey[%s]'
EXTENSION
public
mixed
EXTENSION
= '.doctrinecache.php'
Properties
$directory
The cache directory.
protected
string
$directory
$directoryStringLength
private
int
$directoryStringLength
$extension
The cache file extension.
private
string
$extension
$extensionStringLength
private
int
$extensionStringLength
$isRunningOnWindows
private
bool
$isRunningOnWindows
$namespace
The namespace to prefix all cache ids with.
private
string
$namespace
= ''
$namespaceVersion
The namespace version.
private
int|null
$namespaceVersion
$umask
private
int
$umask
Methods
__construct()
Constructor.
public
__construct(mixed $directory[, mixed $extension = self::EXTENSION ][, mixed $umask = 02 ]) : mixed
Parameters
- $directory : mixed
-
The cache directory.
- $extension : mixed = self::EXTENSION
-
The cache file extension.
- $umask : mixed = 02
Return values
mixed —contains()
Tests if an entry exists in the cache.
public
contains(mixed $id) : bool
Parameters
- $id : mixed
-
The cache id of the entry to check for.
Return values
bool —TRUE if a cache entry exists for the given cache id, FALSE otherwise.
delete()
Deletes a cache entry.
public
delete(mixed $id) : bool
Parameters
- $id : mixed
-
The cache id.
Return values
bool —TRUE if the cache entry was successfully deleted, FALSE otherwise. Deleting a non-existing entry is considered successful.
deleteAll()
Deletes all cache entries in the current cache namespace.
public
deleteAll() : bool
Return values
bool —TRUE if the cache entries were successfully deleted, FALSE otherwise.
fetch()
Fetches an entry from the cache.
public
fetch(mixed $id) : mixed
Parameters
- $id : mixed
-
The id of the cache entry to fetch.
Return values
mixed —The cached data or FALSE, if no cache entry exists for the given id.
fetchMultiple()
Returns an associative array of values for keys is found in cache.
public
fetchMultiple(array<string|int, mixed> $keys) : array<string|int, mixed>
Parameters
- $keys : array<string|int, mixed>
-
Array of keys to retrieve from cache
Return values
array<string|int, mixed> —Array of retrieved values, indexed by the specified keys. Values that couldn't be retrieved are not contained in this array.
flushAll()
Flushes all cache entries, globally.
public
flushAll() : bool
Return values
bool —TRUE if the cache entries were successfully flushed, FALSE otherwise.
getDirectory()
Gets the cache directory.
public
getDirectory() : string
Return values
string —getExtension()
Gets the cache file extension.
public
getExtension() : string
Return values
string —getNamespace()
Retrieves the namespace that prefixes all cache ids.
public
getNamespace() : string
Return values
string —getStats()
Retrieves cached information from the data store.
public
getStats() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null —An associative array with server's statistics if available, NULL otherwise.
save()
Puts data into the cache.
public
save(mixed $id, mixed $data, mixed $lifeTime) : bool
Parameters
- $id : mixed
-
The cache id.
- $data : mixed
-
The cache entry/data.
- $lifeTime : mixed
-
The lifetime in number of seconds for this cache entry. If zero (the default), the entry never expires (although it may be deleted from the cache to make place for other entries).
Return values
bool —TRUE if the entry was successfully stored in the cache, FALSE otherwise.
saveMultiple()
Returns a boolean value indicating if the operation succeeded.
public
saveMultiple(array<string|int, mixed> $keysAndValues, mixed $lifetime) : bool
Parameters
- $keysAndValues : array<string|int, mixed>
-
Array of keys and values to save in cache
- $lifetime : mixed
-
The lifetime. If != 0, sets a specific lifetime for these cache entries (0 => infinite lifeTime).
Return values
bool —TRUE if the operation was successful, FALSE if it wasn't.
setNamespace()
Sets the namespace to prefix all cache ids with.
public
setNamespace(string $namespace) : void
Parameters
- $namespace : string
Return values
void —doContains()
{@inheritdoc}
protected
doContains(mixed $id) : mixed
Parameters
- $id : mixed
Return values
mixed —doDelete()
Deletes a cache entry.
protected
abstract doDelete(string $id) : bool
Parameters
- $id : string
-
The cache id.
Return values
bool —TRUE if the cache entry was successfully deleted, FALSE otherwise.
doFetch()
{@inheritdoc}
protected
doFetch(mixed $id) : mixed
Parameters
- $id : mixed
Return values
mixed —doFetchMultiple()
Default implementation of doFetchMultiple. Each driver that supports multi-get should owerwrite it.
protected
doFetchMultiple(array<string|int, mixed> $keys) : array<string|int, mixed>
Parameters
- $keys : array<string|int, mixed>
-
Array of keys to retrieve from cache
Return values
array<string|int, mixed> —Array of values retrieved for the given keys.
doFlush()
Flushes all cache entries.
protected
abstract doFlush() : bool
Return values
bool —TRUE if the cache entries were successfully flushed, FALSE otherwise.
doGetStats()
Retrieves cached information from the data store.
protected
abstract doGetStats() : array<string|int, mixed>|null
Tags
Return values
array<string|int, mixed>|null —An associative array with server's statistics if available, NULL otherwise.
doSave()
{@inheritdoc}
protected
doSave(mixed $id, mixed $data, mixed $lifeTime) : mixed
Parameters
- $id : mixed
- $data : mixed
- $lifeTime : mixed
Return values
mixed —doSaveMultiple()
Default implementation of doSaveMultiple. Each driver that supports multi-put should override it.
protected
doSaveMultiple(array<string|int, mixed> $keysAndValues, int $lifetime) : bool
Parameters
- $keysAndValues : array<string|int, mixed>
-
Array of keys and values to save in cache
- $lifetime : int
-
The lifetime. If != 0, sets a specific lifetime for these cache entries (0 => infinite lifeTime).
Return values
bool —TRUE if the operation was successful, FALSE if it wasn't.
getFilename()
protected
getFilename(string $id) : string
Parameters
- $id : string
Return values
string —writeFile()
Writes a string content to file in an atomic way.
protected
writeFile(string $filename, string $content) : bool
Parameters
- $filename : string
-
Path to the file where to write the data.
- $content : string
-
The content to write
Return values
bool —TRUE on success, FALSE if path cannot be created, if path is not writable or an any other error.
createPathIfNeeded()
Create path if needed.
private
createPathIfNeeded(string $path) : bool
Parameters
- $path : string
Return values
bool —TRUE on success or if path already exists, FALSE if path cannot be created.
getIterator()
private
getIterator() : Iterator
Return values
Iterator —getNamespaceCacheKey()
Returns the namespace cache key.
private
getNamespaceCacheKey() : string
Return values
string —getNamespacedId()
Prefixes the passed id with the configured namespace value.
private
getNamespacedId(string $id) : string
Parameters
- $id : string
-
The id to namespace.
Return values
string —The namespaced id.
getNamespaceVersion()
Returns the namespace version.
private
getNamespaceVersion() : int
Return values
int —includeFileForId()
private
includeFileForId(string $id) : array<string|int, mixed>|false
Parameters
- $id : string
Return values
array<string|int, mixed>|false —isFilenameEndingWithExtension()
private
isFilenameEndingWithExtension(string $name) : bool
Parameters
- $name : string
-
The filename