Download the PHP package globalis/wp-cubi-transient-cache without Composer
On this page you can find all versions of the php package globalis/wp-cubi-transient-cache. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package wp-cubi-transient-cache
wp-cubi-transient-cache
Persistent cache library based on WordPress transients
Features
- Provides
Cache::set()
andCache::get()
methods, using transients - Provides
Template::get()
method, that automatically caches required template part - Automatically cache WordPress nav-menus out of the box
- Clear cache by group, when menus are saved, when posts are saved, when site URL changes
Installation
Usage
Generic caching
Save a value in cache :
Get a value from cache :
Clear a single cache entry :
Clear multiple cache entries :
Templates caching
Get a template part from cache :
When a template part cache value doesn't exists, Template::get()
will automatically loads required template part, and cache it, so you just have to replace calls to WordPress core function get_template_part()
with Template::get()
to enable cache on a template part.
Templates cache uses generic clear methods, using file path as key (e.g. Cache::clear('templates/my-part', 'my_group');
).
Nav-menus caching
Nav-menus are automatically cached and several hooks are setup out of the box to clear their cache when needed.
You can always manually clear all menus cache with :
Procedural style
Most of the above methods can be called in a procedural style, without any namespace :
Configuration
Bypass cache when developping, or in a specific environment config file :
Bypass cache only for template parts :
Disable nav-menus automatic caching :
Hooks
Clear all cache :
Filter clear hooks :
Development
Before opening pull requests, please check and apply project coding standards with ./vendor/bin/phpcs .
and/or ./vendor/bin/phpcbf .