WPCacheEngine
in package
implements
CacheEngine
Uses
CacheNameSpaceTrait
Implementation of CacheEngine that uses the built-in WordPress cache.
Interfaces, Classes and Traits
- CacheEngine
- Interface for cache engines used by objects inheriting from ObjectCache.
Table of Contents
- cache_object() : bool
- Caches an object under a given key, and with a given expiration.
- delete_cache_group() : bool
- Deletes all cached objects under a given group.
- delete_cached_object() : bool
- Removes a cached object from the cache.
- get_cache_prefix() : string
- Get prefix for use with wp_cache_set. Allows all cache in a group to be invalidated at once.
- get_cached_object() : array<string|int, mixed>|object|null
- Retrieves an object cached under a given key.
- get_prefixed_key() : string
- Helper method to get prefixed key.
- incr_cache_prefix() : mixed
- Increment group cache prefix (invalidates cache).
- invalidate_cache_group() : mixed
- Invalidate cache group.
- is_cached() : bool
- Checks if an object is cached under a given key.
Methods
cache_object()
Caches an object under a given key, and with a given expiration.
public
cache_object(string $key, array<string|int, mixed>|object $object, int $expiration[, string $group = '' ]) : bool
Parameters
- $key : string
-
The key under which the object will be cached.
- $object : array<string|int, mixed>|object
-
The object to cache.
- $expiration : int
-
Expiration for the cached object, in seconds.
- $group : string = ''
-
The group under which the object will be cached.
Return values
bool — True if the object is cached successfully, false otherwise.delete_cache_group()
Deletes all cached objects under a given group.
public
delete_cache_group([string $group = '' ]) : bool
Parameters
- $group : string = ''
-
The group to delete.
Return values
bool — True if the group is deleted successfully, false otherwise.delete_cached_object()
Removes a cached object from the cache.
public
delete_cached_object(string $key[, string $group = '' ]) : bool
Parameters
- $key : string
-
They key under which the object is cached.
- $group : string = ''
-
The group under which the object is cached.
Return values
bool — True if the object is removed from the cache successfully, false otherwise (because the object wasn't cached or for other reason).get_cache_prefix()
Get prefix for use with wp_cache_set. Allows all cache in a group to be invalidated at once.
public
static get_cache_prefix(string $group) : string
Parameters
- $group : string
-
Group of cache to get.
Return values
string — Prefix.get_cached_object()
Retrieves an object cached under a given key.
public
get_cached_object(string $key[, string $group = '' ]) : array<string|int, mixed>|object|null
Parameters
- $key : string
-
They key under which the object to retrieve is cached.
- $group : string = ''
-
The group under which the object is cached.
Return values
array<string|int, mixed>|object|null — The cached object, or null if there's no object cached under the passed key.get_prefixed_key()
Helper method to get prefixed key.
public
static get_prefixed_key(string $key, string $group) : string
Parameters
- $key : string
-
Key to prefix.
- $group : string
-
Group of cache to get.
Return values
string — Prefixed key.incr_cache_prefix()
Increment group cache prefix (invalidates cache).
public
static incr_cache_prefix(string $group) : mixed
Parameters
- $group : string
-
Group of cache to clear.
Return values
mixed —invalidate_cache_group()
Invalidate cache group.
public
static invalidate_cache_group(string $group) : mixed
Parameters
- $group : string
-
Group of cache to clear.
Tags
Return values
mixed —is_cached()
Checks if an object is cached under a given key.
public
is_cached(string $key[, string $group = '' ]) : bool
Parameters
- $key : string
-
The key to verify.
- $group : string = ''
-
The group under which the object is cached.