Constants

DOCTRINE_NAMESPACE_CACHEKEY

DOCTRINE_NAMESPACE_CACHEKEY = 'DoctrineNamespaceCacheKey[%s]'

EXTENSION

EXTENSION = '.doctrinecache.php'

Properties

$directory

$directory : string

The cache directory.

Type

string

$extension

$extension : string

The cache file extension.

Type

string

$disallowedCharacterPatterns

$disallowedCharacterPatterns : array<mixed,string>

Type

array<mixed,string> — regular expressions for replacing disallowed characters in file name

$replacementCharacters

$replacementCharacters : array<mixed,string>

Type

array<mixed,string> — replacements for disallowed file characters

$umask

$umask : integer

Type

integer

$namespace

$namespace : string

The namespace to prefix all cache ids with.

Type

string

$namespaceVersion

$namespaceVersion : integer|null

The namespace version.

Type

integer|null

Methods

__construct()

__construct(string  $directory, string  $extension = self::EXTENSION,   $umask = 2) 

Constructor.

Parameters

string $directory

The cache directory.

string $extension

The cache file extension.

$umask

getDirectory()

getDirectory() : string

Gets the cache directory.

Returns

string

getExtension()

getExtension() : string|null

Gets the cache file extension.

Returns

string|null

setNamespace()

setNamespace(string  $namespace) : void

Sets the namespace to prefix all cache ids with.

Parameters

string $namespace

getNamespace()

getNamespace() : string

Retrieves the namespace that prefixes all cache ids.

Returns

string

fetch()

fetch(string  $id) : mixed

Fetches an entry from the cache.

Parameters

string $id

The id of the cache entry to fetch.

Returns

mixed —

The cached data or FALSE, if no cache entry exists for the given id.

fetchMultiple()

fetchMultiple(array  $keys) : array<mixed,mixed>

Returns an associative array of values for keys is found in cache.

Parameters

array $keys

Array of keys to retrieve from cache

Returns

array<mixed,mixed> —

Array of retrieved values, indexed by the specified keys. Values that couldn't be retrieved are not contained in this array.

contains()

contains(string  $id) : boolean

Tests if an entry exists in the cache.

Parameters

string $id

The cache id of the entry to check for.

Returns

boolean —

TRUE if a cache entry exists for the given cache id, FALSE otherwise.

save()

save(string  $id, mixed  $data, integer  $lifeTime) : boolean

Puts data into the cache.

If a cache entry with the given id already exists, its data will be replaced.

Parameters

string $id

The cache id.

mixed $data

The cache entry/data.

integer $lifeTime

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).

Returns

boolean —

TRUE if the entry was successfully stored in the cache, FALSE otherwise.

delete()

delete(string  $id) : boolean

Deletes a cache entry.

Parameters

string $id

The cache id.

Returns

boolean —

TRUE if the cache entry was successfully deleted, FALSE otherwise. Deleting a non-existing entry is considered successful.

getStats()

getStats() : array|null

Retrieves cached information from the data store.

The server's statistics array has the following values:

  • hits Number of keys that have been requested and found present.

  • misses Number of items that have been requested and not found.

  • uptime Time that the server is running.

  • memory_usage Memory used by this server to store items.

  • memory_available Memory allowed to use for storage.

Returns

array|null —

An associative array with server's statistics if available, NULL otherwise.

flushAll()

flushAll() : boolean

Flushes all cache entries, globally.

Returns

boolean —

TRUE if the cache entries were successfully flushed, FALSE otherwise.

deleteAll()

deleteAll() : boolean

Deletes all cache entries in the current cache namespace.

Returns

boolean —

TRUE if the cache entries were successfully deleted, FALSE otherwise.

getFilename()

getFilename(string  $id) : string

Parameters

string $id

Returns

string

doDelete()

doDelete(string  $id) : boolean

Deletes a cache entry.

Parameters

string $id

The cache id.

Returns

boolean —

TRUE if the cache entry was successfully deleted, FALSE otherwise.

doFlush()

doFlush() : boolean

Flushes all cache entries.

Returns

boolean —

TRUE if the cache entries were successfully flushed, FALSE otherwise.

doGetStats()

doGetStats() : array|null

Retrieves cached information from the data store.

Returns

array|null —

An associative array with server's statistics if available, NULL otherwise.

writeFile()

writeFile(string  $filename, string  $content) : boolean

Writes a string content to file in an atomic way.

Parameters

string $filename

Path to the file where to write the data.

string $content

The content to write

Returns

boolean —

TRUE on success, FALSE if path cannot be created, if path is not writable or an any other error.

doFetchMultiple()

doFetchMultiple(array  $keys) : array

Default implementation of doFetchMultiple. Each driver that supports multi-get should owerwrite it.

Parameters

array $keys

Array of keys to retrieve from cache

Returns

array —

Array of values retrieved for the given keys.

doFetch()

doFetch(  $id) 

{@inheritdoc}

Parameters

$id

doContains()

doContains(  $id) 

{@inheritdoc}

Parameters

$id

doSave()

doSave(  $id,   $data,   $lifeTime) 

{@inheritdoc}

Parameters

$id
$data
$lifeTime

createPathIfNeeded()

createPathIfNeeded(string  $path) : boolean

Create path if needed.

Parameters

string $path

Returns

boolean —

TRUE on success or if path already exists, FALSE if path cannot be created.

getIterator()

getIterator() : \Iterator

Returns

\Iterator

isFilenameEndingWithExtension()

isFilenameEndingWithExtension(string  $name) : boolean

Parameters

string $name

The filename

Returns

boolean

getNamespacedId()

getNamespacedId(string  $id) : string

Prefixes the passed id with the configured namespace value.

Parameters

string $id

The id to namespace.

Returns

string —

The namespaced id.

getNamespaceCacheKey()

getNamespaceCacheKey() : string

Returns the namespace cache key.

Returns

string

getNamespaceVersion()

getNamespaceVersion() : integer

Returns the namespace version.

Returns

integer

includeFileForId()

includeFileForId(string  $id) : array|false

Parameters

string $id

Returns

array|false