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 today

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 47% 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

3722d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/761287?v=4)[Andrej Cremoznik](/maintainers/andrejcremoznik)[@andrejcremoznik](https://github.com/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

[beryllium/cachebundle

Provides an interface to Memcache for Symfony2 applications

32136.0k](/packages/beryllium-cachebundle)

PHPackages © 2026

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