Documentation

Cache

Interface for cache drivers.

Tags
link
www.doctrine-project.org

Table of Contents

Constants

STATS_HITS  = 'hits'
STATS_MEMORY_AVAILABLE  = 'memory_available'
STATS_MEMORY_AVAILIABLE  = 'memory_available'
Only for backward compatibility (may be removed in next major release)
STATS_MEMORY_USAGE  = 'memory_usage'
STATS_MISSES  = 'misses'
STATS_UPTIME  = 'uptime'

Methods

contains()  : bool
Tests if an entry exists in the cache.
delete()  : bool
Deletes a cache entry.
fetch()  : mixed
Fetches an entry from the cache.
getStats()  : array<string|int, mixed>|null
Retrieves cached information from the data store.
save()  : bool
Puts data into the cache.

Constants

STATS_HITS

public mixed STATS_HITS = 'hits'

STATS_MEMORY_AVAILABLE

public mixed STATS_MEMORY_AVAILABLE = 'memory_available'

STATS_MEMORY_AVAILIABLE

Only for backward compatibility (may be removed in next major release)

public mixed STATS_MEMORY_AVAILIABLE = 'memory_available'
Tags
deprecated

STATS_MEMORY_USAGE

public mixed STATS_MEMORY_USAGE = 'memory_usage'

STATS_MISSES

public mixed STATS_MISSES = 'misses'

STATS_UPTIME

public mixed STATS_UPTIME = 'uptime'

Methods

contains()

Tests if an entry exists in the cache.

public contains(string $id) : bool
Parameters
$id : string

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(string $id) : bool
Parameters
$id : string

The cache id.

Return values
bool

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

fetch()

Fetches an entry from the cache.

public fetch(string $id) : mixed
Parameters
$id : string

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.

getStats()

Retrieves cached information from the data store.

public getStats() : array<string|int, mixed>|null

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.

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(string $id, mixed $data[, int $lifeTime = 0 ]) : bool

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

Parameters
$id : string

The cache id.

$data : mixed

The cache entry/data.

$lifeTime : int = 0

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.


        
On this page

Search results