← All PHP Libraries
PHP Library Open source · GPL-2.0-or-later PHP

WP Cache Helper

A cleaner API over the WordPress object cache and transients.

View on Packagist
  • Unified API over the object cache and the transients API
  • Group flush support to invalidate related entries at once
  • Per-prefix scoping to avoid key collisions
  • A swappable driver layer for testing and portability
Overview

About WP Cache Helper

Helper library for the WordPress object cache and transients — group flush support, per-prefix scoping, and a swappable driver layer.

What it does

WP Cache Helper wraps the WordPress object cache and transients behind one small, consistent API — with grouped invalidation, prefixed keys, and a driver layer you can swap out in tests.

Install with Composer:

BASH
composer require foxelabs/wp-cache-helper

Frequently asked questions

What does WP Cache Helper do?

It puts one API over both the WordPress object cache and the transients API, so caching code does not change shape depending on which backing store it uses. It adds group flushing, per-prefix key scoping, and a swappable driver layer on top.

How do I flush a group of related cache entries in WordPress?

WordPress core has no portable group flush — `wp_cache_flush_group()` depends on the object cache drop-in supporting it. WP Cache Helper implements grouping itself, so invalidating every entry in a group works the same whether you are on a persistent object cache or falling back to transients.

Why use per-prefix scoping?

Cache keys are a global namespace shared with core, themes, and every other plugin. Scoping your keys under a prefix means a generic key name cannot collide with someone else's, and it makes your plugin's entries identifiable when you need to clear them.

Can I use it without a persistent object cache?

Yes. Without a persistent object cache the driver layer falls back to the transients API, so the same calls keep working — just backed by the database instead of memory.

Learn how we can help you build better.

Questions about a plugin, a licence, or an expert advisor — ask and get a straight answer from the team that wrote the code.

Contact us Browse the software