Apcu4Backend deprecated
class Apcu4Backend extends ApcuBackend (View source)
deprecated
Stores cache items in the Alternative PHP Cache User Cache (APCu).
This class is used with APCu versions >= 4.0.0 and < 5.0.0.
Properties
| protected string | $bin | The name of the cache bin to use. |
from ApcuBackend |
| protected string | $sitePrefix | Prefix for all keys in the storage that belong to this site. |
from ApcuBackend |
| protected string | $binPrefix | Prefix for all keys in this cache bin. |
from ApcuBackend |
| protected CacheTagsChecksumInterface | $checksumProvider | The cache tags checksum provider. |
from ApcuBackend |
Methods
Constructs a new ApcuBackend instance.
Prepends the APCu user variable prefix for this bin to a cache item ID.
Returns data from the persistent cache.
Returns data from the persistent cache when given an array of cache IDs.
Returns all cached items, optionally limited by a cache ID prefix.
Stores data in the persistent cache.
Instantiates and returns the APCUIterator class.
Details
__construct(string $bin, string $site_prefix, CacheTagsChecksumInterface $checksum_provider)
Constructs a new ApcuBackend instance.
string
getApcuKey(string $cid)
Prepends the APCu user variable prefix for this bin to a cache item ID.
object|false
get(string $cid, bool $allow_invalid = FALSE)
Returns data from the persistent cache.
array
getMultiple(array $cids, bool $allow_invalid = FALSE)
Returns data from the persistent cache when given an array of cache IDs.
protected APCUIterator
getAll(string $prefix = '')
Returns all cached items, optionally limited by a cache ID prefix.
APCu is a memory cache, shared across all server processes. To prevent cache item clashes with other applications/installations, every cache item is prefixed with a unique string for this site. Therefore, functions like apcu_clear_cache() cannot be used, and instead, a list of all cache items belonging to this application need to be retrieved through this method instead.
protected mixed
prepareItem(object $cache, bool $allow_invalid)
Prepares a cached item.
Checks that the item is either permanent or did not expire.
set(string $cid, mixed $data, int $expire = CacheBackendInterface::CACHE_PERMANENT, array $tags = [])
Stores data in the persistent cache.
Core cache implementations set the created time on cache item with microtime(TRUE) rather than REQUEST_TIME_FLOAT, because the created time of cache items should match when they are created, not when the request started. Apart from being more accurate, this increases the chance an item will legitimately be considered valid.
setMultiple(array $items = [])
Store multiple items in the persistent cache.
delete(string $cid)
Deletes an item from the cache.
If the cache item is being deleted because it is no longer "fresh", you may consider using invalidate() instead. This allows callers to retrieve the invalid item by calling get() with $allow_invalid set to TRUE. In some cases an invalid item may be acceptable rather than having to rebuild the cache.
deleteMultiple(array $cids)
Deletes multiple items from the cache.
If the cache items are being deleted because they are no longer "fresh", you may consider using invalidateMultiple() instead. This allows callers to retrieve the invalid items by calling get() with $allow_invalid set to TRUE. In some cases an invalid item may be acceptable rather than having to rebuild the cache.
deleteAll()
Deletes all cache items in a bin.
garbageCollection()
Performs garbage collection on a cache bin.
The backend may choose to delete expired or invalidated items.
removeBin()
Remove a cache bin.
invalidate(string $cid)
Marks a cache item as invalid.
Invalid items may be returned in later calls to get(), if the $allow_invalid argument is TRUE.
invalidateMultiple(array $cids)
Marks cache items as invalid.
Invalid items may be returned in later calls to get(), if the $allow_invalid argument is TRUE.
invalidateAll()
Marks all cache items as invalid.
Invalid items may be returned in later calls to get(), if the $allow_invalid argument is TRUE.
protected APCUIterator
getIterator(mixed $search = NULL, int $format = APC_ITER_ALL, int $chunk_size = 100, int $list = APC_LIST_ACTIVE)
Instantiates and returns the APCUIterator class.