Download the PHP package helick/cache-helpers without Composer
On this page you can find all versions of the php package helick/cache-helpers. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package cache-helpers
Helick Cache Helpers
Helpers for the WordPress object cache and transients.
Requirements
Make sure all dependencies have been installed before moving on:
Install
Via Composer:
Usage
The package provides the following functions for WordPress:
cache_remember()
cache_forget()
transient_remember()
transient_forget()
site_transient_remember()
site_transient_forget()
Each function checks the response of the callback for a WP_Error
object, ensuring you're not caching temporary errors for long periods of time. PHP Exceptions will also not be cached.
cache_remember()
Get a value from the object cache, if one doesn't exist, run the given callback to generate and cache the value.
Parameters
- (string) $key
- The cache key.
- (callable) $callback
- The callback used to generate and cache the value.
- (string) $group
- Optional. The cache group. Default is empty.
- (int) $expire
- Optional. The number of seconds before the cache entry should expire. Default is 0 (as long as possible).
Example
cache_forget()
Get and subsequently delete a value from the object cache.
Parameters
- (string) $key
- The cache key.
- (string) $group
- Optional. The cache group. Default is empty.
- (mixed) $default
- Optional. The default value to return if the given key doesn't exist in the object cache. Default is null.
Example
transient_remember()
Get a value from the transients, if one doesn't exist, run the given callback to generate and cache the value.
Parameters
- (string) $key
- The cache key.
- (callable) $callback
- The callback used to generate and cache the value.
- (int) $expire
- Optional. The number of seconds before the cache entry should expire. Default is 0 (as long as possible).
Example
transient_forget()
Get and subsequently delete a value from the transients.
Parameters
- (string) $key
- The cache key.
- (mixed) $default
- Optional. The default value to return if the given key doesn't exist in transients. Default is null.
site_transient_remember()
Get a value from the transients, if one doesn't exist, run the given callback to generate and cache the value.
This function shares arguments and behavior with transient_remember()
, but works network-wide when using WordPress Multisite.
Parameters
- (string) $key
- The cache key.
- (mixed) $default
- Optional. The default value to return if the given key doesn't exist in transients. Default is null.
site_transient_forget()
Get and subsequently delete a value from the site transients.
This function shares arguments and behavior with transient_forget()
, but works network-wide when using WordPress Multisite.
Parameters
- (string) $key
- The cache key.
- (mixed) $default
- Optional. The default value to return if the given key doesn't exist in transients. Default is null.
Contributing
Please see CODE_OF_CONDUCT for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Evgenii Nasyrov
- All Contributors
License
The MIT License (MIT). Please see License File for more information.