Download the PHP package snicco/better-wp-cache without Composer
On this page you can find all versions of the php package snicco/better-wp-cache. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package better-wp-cache
BetterWPCache - A PSR-16/PSR-6 cache implementation using the WordPress object cache
BetterWPCache is a tiny library that allows you to use the persistent WordPress object cache as a PSR-16 cache or a PSR-6 cache.
Additionally, BetterWPCache supports cache tagging.
This library is 100% integration tested against the official php-cache/integration-tests using the Redis Object Cache plugin by Till Krüss.
Table of contents
- Motivation
- Installation
- Usage
- [Does this work with any caching plugin?]()
- PSR-6
- PSR-16
- Cache Tagging
- Contributing
- Issues and PR's
- Security
Motivation
We developed this library because many WordPress related components of the Snicco project require some form of caching.
To offer the greatest flexibility for users, they all only depend on the PSR cache interfaces.
But using these interfaces' meant that there was no way of using these components inside WordPress
with the already connected WP_Object_Cache
.
BetterWPCache solves this need.
This library has three main use cases:
- You are developing a distributed WordPress library and don't want to depend on the
WP_Object_Cache
. - You are using any PHP package that depends on the PSR cache interface, and you want to use your WordPress caching plugin for it.
- You want cache-tagging, which is something that the
WP_Object_Cache
does not support.
Ideally, WordPress core would replace the custom WP_Object_Cache
with the PSR cache interface instead, so that
the need for this library vanishes. In the meantime BetterWPCache will do the job.
Installation
Usage
Does this work with any caching plugin?
Short answer: Yes!
Long answer: As long as your caching plugin correctly implements the wp_cache_xxx
functions. This library only uses
the
official WordPress cache functions.
Creating a PSR-6 cache
This is how you create a PSR-6 cache from your favorite WordPress cache plugin.
Creating a PSR-16 cache
This is how you create a PSR-16 cache from your favorite WordPress cache plugin.
Cache tagging
For cache tagging a PSR-6 cache is needed.
$taggable_cache
is an instance of TaggableCacheItemPoolInterface which
is in the process of becoming a PSR standard.
Taken from the official documentation:
Contributing
This repository is a read-only split of the development repo of the Snicco project.
This is how you can contribute.
Reporting issues and sending pull requests
Please report issues in the Snicco monorepo.
Security
If you discover a security vulnerability within BetterWPCache, please follow our disclosure procedure.
All versions of better-wp-cache with dependencies
cache/simple-cache-bridge Version ^1.2.0
cache/tag-interop Version ^1.1
cache/taggable-cache Version 1.2.0
psr/cache Version ^1.0.0
psr/simple-cache Version ^1.0.0
snicco/better-wp-api Version ^2.0