Download the PHP package duckdev/wp-cache-helper without Composer

On this page you can find all versions of the php package duckdev/wp-cache-helper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package wp-cache-helper

WP Cache Helper

WP Cache Helper is a small WordPress library that wraps the object cache and transient APIs with a callback-style remember() helper, group-flush support for the object cache (delegating to core's wp_cache_flush_group() on WP 6.1+ backends that support it, with a version-sentinel fallback for backends that don't), and per-prefix scoping so multiple consumers on the same site never collide.

Inspired by WP Cache Remember.

📖 Full documentation: docs.foxelabs.com

Requirements

Installation

The library autoloads under the FoxeLabs\Cache\ namespace via PSR-4.

Architecture

The library is organised as a tiny container wired up by the entry class FoxeLabs\Cache\Cache. The folder layout mirrors the namespace:

Services receive their collaborators by constructor injection so they can be unit-tested without WordPress in the loop. Construction has no side effects.

Usage

Initialisation

Each container instance is scoped to a single prefix. Pass any non-empty string the first time you ask for it; the same prefix returns the same instance on subsequent calls:

You can also instantiate directly (useful for tests where you want to inject custom drivers):

Every key, group, and the {prefix}_can_cache toggle filter are namespaced under the supplied prefix.

Provided helpers

Method Backed by Purpose
remember() Object cache Read, or compute + cache on miss.
forget() Object cache Read then delete; return a default on miss.
persist() Transients Read, or compute + cache on miss.
cease() Transients Read then delete; return a default on miss.
flush_group() Object cache Invalidate every entry in a group.
flush() Object cache Flush the entire object cache. Last resort.
object_cache() / transient_cache() — Access the underlying driver for finer-grained control.

Every callback-based helper checks the return value with is_wp_error() and skips caching when one is returned, so a transient API failure is not memorised.

Disabling caching

For debugging, return false from the {prefix}_can_cache filter:

The second argument is the cache type — 'object' or 'transient' — so the two can be toggled independently.

Cache::remember()

Retrieve a value from the object cache. If it doesn't exist, run the $callback to generate and cache the value.

Unlike a naive wp_cache_get()-then-fall-back pattern, remember() distinguishes a legitimately cached 0, '', [], or false from a true miss — the callback only runs when nothing was cached.

Cache::forget()

Retrieve a value from the object cache then delete it. Returns $default on miss.

Cache::persist()

Same shape as remember() but backed by the transient API.

Pass true for the third argument to use site-wide (multisite) transients.

Note: transients use boolean false as the miss sentinel, so a legitimately cached false value is indistinguishable from a miss. Reach for remember() if you need to cache false.

Cache::cease()

Transient counterpart to forget().

Cache::flush_group()

Invalidate every entry stored under a group, without touching the rest of the object cache. On WP 6.1+ with a persistent object cache backend that advertises flush_group support (via wp_cache_supports( 'flush_group' )), this delegates straight to wp_cache_flush_group(). Otherwise it falls back to incrementing a per-group version sentinel — old entries become unreadable on next access.

Cache::flush()

Wrapper for wp_cache_flush() with a fallback to $wp_object_cache->flush() when the function is disabled by a drop-in. Clears every group on the site, so use only as a last resort.

Upgrading from 2.x

3.0.0 is the DuckDev → Foxe Labs rebrand. Update your composer.json require entry and every use statement:

[!NOTE] No cache data migration is needed. Keys, groups and the can_cache filter are all built from your own prefix, not from a vendor name, so nothing the library reads or writes changes.

Upgrading from 1.x

The public method surface (remember, forget, persist, cease, flush_group, flush) is otherwise unchanged.

[!WARNING] The 1.x prefix change orphans data rather than losing it, and the two stores behave differently. Object cache entries under duckdev_cache_* are non-persistent and simply vanish on the next flush or restart — ignore them. Transients are the ones to clean up: those written without an expiry persist as wp_options rows that nothing will ever read or expire again. Clear them once from your upgrade routine:

Direct SQL is correct here — this deletes rows nothing reads, and wp_cache_flush() afterwards drops any stale copies from a persistent object cache. There is no data worth carrying forward: every entry is a rebuildable cache value, so let remember() repopulate on the next request rather than migrating.

Development

Credits

License

GPLv2+


All versions of wp-cache-helper with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package duckdev/wp-cache-helper contains the following files

Loading the files please wait ...