OrderCountCache
in package
A class to cache counts for various order statuses.
Table of Contents
- $expiration : int
- Default value for the duration of the objects in the cache, in seconds (may not be used depending on the cache engine used WordPress cache implementation).
- $cache_prefix : string
- Cache prefix.
- decrement() : int
- Decrement the cache value for a given order status.
- flush() : void
- Flush the cache for a given order type and statuses.
- get() : array<string|int, int>
- Get the cache value for a given order type and status.
- get_default_statuses() : array<string|int, string>
- Get the default statuses.
- increment() : int
- Increment the cache value for a given order status.
- is_cached() : bool
- Check if the cache has a value for a given order type and status.
- set() : bool
- Set the cache value for a given order type and status.
- get_cache_key() : string
- Get the cache key for a given order type and status.
- get_valid_statuses() : array<string|int, string>
- Get valid statuses.
Properties
$expiration
Default value for the duration of the objects in the cache, in seconds (may not be used depending on the cache engine used WordPress cache implementation).
protected
int
$expiration
= DAY_IN_SECONDS
$cache_prefix
Cache prefix.
private
string
$cache_prefix
= 'order-count'
Methods
decrement()
Decrement the cache value for a given order status.
public
decrement(string $order_type, string $order_status[, int $offset = 1 ]) : int
Parameters
- $order_type : string
-
The type of order.
- $order_status : string
-
The status of the order.
- $offset : int = 1
-
The amount to decrement by.
Return values
int — The new value of the cache.flush()
Flush the cache for a given order type and statuses.
public
flush([string $order_type = 'shop_order' ][, array<string|int, string> $order_statuses = array() ]) : void
Parameters
- $order_type : string = 'shop_order'
-
The type of order.
- $order_statuses : array<string|int, string> = array()
-
The statuses of the order.
Return values
void —get()
Get the cache value for a given order type and status.
public
get(string $order_type[, array<string|int, string> $order_statuses = array() ]) : array<string|int, int>
Parameters
- $order_type : string
-
The type of order.
- $order_statuses : array<string|int, string> = array()
-
The statuses of the order.
Return values
array<string|int, int> — The cache value.get_default_statuses()
Get the default statuses.
public
get_default_statuses() : array<string|int, string>
Return values
array<string|int, string> —increment()
Increment the cache value for a given order status.
public
increment(string $order_type, string $order_status[, int $offset = 1 ]) : int
Parameters
- $order_type : string
-
The type of order.
- $order_status : string
-
The status of the order.
- $offset : int = 1
-
The amount to increment by.
Return values
int — The new value of the cache.is_cached()
Check if the cache has a value for a given order type and status.
public
is_cached(string $order_type, string $order_status) : bool
Parameters
- $order_type : string
-
The type of order.
- $order_status : string
-
The status of the order.
Return values
bool — True if the cache has a value, false otherwise.set()
Set the cache value for a given order type and status.
public
set(string $order_type, string $order_status, int $value) : bool
Parameters
- $order_type : string
-
The type of order.
- $order_status : string
-
The status of the order.
- $value : int
-
The value to set.
Return values
bool — True if the value was set, false otherwise.get_cache_key()
Get the cache key for a given order type and status.
private
get_cache_key(string $order_type, string $order_status) : string
Parameters
- $order_type : string
-
The type of order.
- $order_status : string
-
The status of the order.
Return values
string — The cache key.get_valid_statuses()
Get valid statuses.
private
get_valid_statuses() : array<string|int, string>