PHPackages                             andrejcremoznik/wp-cache-helper - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. andrejcremoznik/wp-cache-helper

AbandonedArchivedLibrary[Caching](/categories/caching)

andrejcremoznik/wp-cache-helper
===============================

Wrapper for WordPress caching functions

1.0.1(10y ago)0173MITPHPPHP &gt;= 5.6

Since Apr 21Pushed 10y agoCompare

[ Source](https://github.com/andrejcremoznik/wp-cache-helper)[ Packagist](https://packagist.org/packages/andrejcremoznik/wp-cache-helper)[ Docs](https://github.com/andrejcremoznik/wp-cache-helper)[ RSS](/packages/andrejcremoznik-wp-cache-helper/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (3)Used By (0)

WP Cache Helper
===============

[](#wp-cache-helper)

A wrapper class for WordPress caching functions.

### What is this?

[](#what-is-this)

WordPress provides some caching functions that make it needlessly hard to invalidate previously saved caches. The idea here is to version cache keys by appending a number. So instead of caching something with a key `mycache` it's cached as `mycacheN` where N is an integer we increment every time the cache needs to be invalidated (like in `save_post` hook).

Installation
------------

[](#installation)

Copy the `src/WpCacheHelper.php` file to your project and require it `require_once('path/to/WpCacheHelper.php');`.

Or with composer: `composer require andrejcremoznik/wp-cache-helper`.

Usage
-----

[](#usage)

```
use \AndrejCremoznik\WpCacheHelper\WpCacheHelper as Cache;

function do_something_expensive() {
    $cache = new Cache('data_key');
    $expensive_data = $cache->get();

    if ($expensive_data === false) {
        $expensive_data = get_expensive_data();
        $cache->set($expensive_data);
    }

    return $expensive_data;
}

echo do_something_expensive();
```

### Invalidate cache on post save / delete

[](#invalidate-cache-on-post-save--delete)

```
function invalidate_cache() {
    Cache::flush()
}
add_action('save_post',    'invalidate_cache');
add_action('deleted_post', 'invalidate_cache');
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

3670d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3587d79f9ccda6b15be8426a15cce441853e9decf94000cfb600e0de69e1d130?d=identicon)[andrejcremoznik](/maintainers/andrejcremoznik)

---

Top Contributors

[![andrejcremoznik](https://avatars.githubusercontent.com/u/761287?v=4)](https://github.com/andrejcremoznik "andrejcremoznik (2 commits)")

### Embed Badge

![Health badge](/badges/andrejcremoznik-wp-cache-helper/health.svg)

```
[![Health](https://phpackages.com/badges/andrejcremoznik-wp-cache-helper/health.svg)](https://phpackages.com/packages/andrejcremoznik-wp-cache-helper)
```

###  Alternatives

[predis/predis

A flexible and feature-complete Redis/Valkey client for PHP.

7.8k305.7M2.4k](/packages/predis-predis)[snc/redis-bundle

A Redis bundle for Symfony

1.0k39.4M67](/packages/snc-redis-bundle)[react/cache

Async, Promise-based cache interface for ReactPHP

444112.4M40](/packages/react-cache)[wp-media/wp-rocket

Performance optimization plugin for WordPress

7431.3M3](/packages/wp-media-wp-rocket)[illuminate/cache

The Illuminate Cache package.

12835.6M1.4k](/packages/illuminate-cache)[colinmollenhour/php-redis-session-abstract

A Redis-based session handler with optimistic locking

6325.6M14](/packages/colinmollenhour-php-redis-session-abstract)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
