Cache
in package
Handles caching and retrieval for service components.
Tags
Table of Contents
Methods
- clear_all() : mixed
- Clears all cached values belonging to this plugin (transients, options, and wp_cache).
- clear_options() : mixed
- Deletes all cached options.
- clear_transients() : mixed
- Deletes all cached transients.
- delete() : bool
- Deletes a cached value.
- flush() : mixed
- Clears all cache in a specific group (wp_cache only).
- get() : mixed
- Retrieves a cached value from the preferred caching method.
- set() : bool
- Stores a value in the cache.
Methods
clear_all()
Clears all cached values belonging to this plugin (transients, options, and wp_cache).
public
static clear_all() : mixed
Tags
clear_options()
Deletes all cached options.
public
static clear_options([string $group = 'default' ]) : mixed
Parameters
- $group : string = 'default'
-
Cache group to clear.
Tags
clear_transients()
Deletes all cached transients.
public
static clear_transients([string $group = 'default' ]) : mixed
Parameters
- $group : string = 'default'
-
Cache group to clear.
Tags
delete()
Deletes a cached value.
public
static delete(string $key[, string $group = 'default' ][, string $type = 'wp_cache' ]) : bool
Parameters
- $key : string
-
The cache key.
- $group : string = 'default'
-
Optional. Cache group for wp_cache.
- $type : string = 'wp_cache'
-
Optional. Cache type: 'wp_cache', 'transient', or 'option'. Default is 'wp_cache'.
Tags
Return values
bool —True on success, false on failure.
flush()
Clears all cache in a specific group (wp_cache only).
public
static flush([string $group = 'default' ]) : mixed
Parameters
- $group : string = 'default'
-
Cache group to clear.
Tags
get()
Retrieves a cached value from the preferred caching method.
public
static get(string $key[, string $group = 'default' ][, string $type = 'wp_cache' ]) : mixed
Parameters
- $key : string
-
The cache key.
- $group : string = 'default'
-
Optional. Cache group for wp_cache. Default is 'default'.
- $type : string = 'wp_cache'
-
Optional. Cache type: 'wp_cache', 'transient', or 'option'. Default is 'wp_cache'.
Tags
Return values
mixed —Cached value or false if not found.
set()
Stores a value in the cache.
public
static set(string $key, mixed $value[, int $expires = HOUR_IN_SECONDS ][, string $group = 'default' ][, string $type = 'wp_cache' ]) : bool
Parameters
- $key : string
-
The cache key.
- $value : mixed
-
The value to store.
- $expires : int = HOUR_IN_SECONDS
-
Expiration time in seconds. Default is 1 hour.
- $group : string = 'default'
-
Optional. Cache group for wp_cache.
- $type : string = 'wp_cache'
-
Optional. Cache type: 'wp_cache', 'transient', or 'option'. Default is 'wp_cache'.
Tags
Return values
bool —True on success, false on failure.