PHPackages                             tekod/wp-cache-controller - 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. tekod/wp-cache-controller

ActiveLibrary[Caching](/categories/caching)

tekod/wp-cache-controller
=========================

WordPress library for caching arbitrary data with automatic invalidation.

1.1.1(2y ago)17.3k↑62.9%1MITPHPPHP &gt;=7.0.0

Since Mar 7Pushed 2y ago1 watchersCompare

[ Source](https://github.com/tekod/WpCacheController)[ Packagist](https://packagist.org/packages/tekod/wp-cache-controller)[ Docs](https://gitlab.com/tekod/WpCacheController)[ RSS](/packages/tekod-wp-cache-controller/feed)WikiDiscussions master Synced today

READMEChangelog (6)DependenciesVersions (7)Used By (0)

[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)[![Issues](https://camo.githubusercontent.com/14a74571e46a559ac354d2421f212a4d284b12ec29ecdf46a03832d8167cdcd2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f74656b6f642f57704361636865436f6e74726f6c6c65722e737667)](https://github.com/tekod/WpCacheController/issues)

WpCacheController
=================

[](#wpcachecontroller)

WordPress library for caching arbitrary data with automatic invalidation

WpCacheController is WordPress library for caching arbitrary data with automatic invalidation. It is framework-agnostic so no other packages are needed for its proper operation.

This lib constantly updates log and statistics records to inform an administrator about cache usage.

There is admin dashboard settings page where administrator can enable/disable caching function and see log records and statistics.

Typical usage for this library is to substitute code blocks that have to access database several times to prepare HTML content, for example: navigation block, category tree, footer, the latest blog posts block, related products block,...

Usage:
======

[](#usage)

Put this in "functions.php" of yours theme to initialize the controller where parameter is path to configuration file:

```
use Tekod\WpCacheController\CacheController;
require_once 'inc/WpCacheController/CacheController.php';  // optional if you use some autoloader
CacheController::Init(__DIR__.'/config/cachecontroller.config.php');

```

Example of configuration is part of this lib. It is highly recommended to clone (and rename) configuration file outside of lib directory and edit content there, just like in code above. That way you can safely update library without losing configuration.

This will echo HTML content identified as "product menu" from cache or include template if not:

```
CacheController::Profile('eCommerce')->Output('product menu', function() {
    get_template_part('template-parts/woocommerce_product_menu');
});

```

Here is how to pass parameter to inner function (closure) to create a dynamic identifier:

```
CacheController::Profile('Shop')->Output('product-page-'.$ProductID, function() use ($ProductID) {
     $Product= new MyProduct($ProductID);
     $Title= $Product->GetTitle();
     $Image= $Product->GetImage();
     include 'shop/single-product.php';
});

```

Instead of echoing content use "Get()" to just return arbitrary data, typical use case is to replace fetching values from a database with heavy SQL queries

```
$Data= CacheController::Profile('Movies')->Get('full-movie-data-'.$ID, function() use ($ID) {
     return [
         'Movie' => get_post($ID),
         'Genres' => get_posts(['posts_per_page' => -1, 'post_type' => 'genre', 'tax_query' => [.....
         'Actors' => get_posts(['posts_per_page' => -1, 'post_type' => 'actor', 'tax_query' => [.....
         'Photos' => get_posts(['posts_per_page' => -1, 'post_type' => 'photo', 'tax_query' => [.....
         ....
     ];
});

```

Note: identifiers must contain only filename-safe chars (regex: "A-Za-z0-9~\_!&amp;= |.-+") easiest method to ensure that is to pass it through md5 func, like:

```
CacheController::Profile('IMDB')->Get(md5($URL), function() {...

```

3rd parameter
-------------

[](#3rd-parameter)

Methods Get and Output has 3rd parameter "OnCacheHit" where you can put code block (closure) that should be executed if content is returned from cache (meaning main closure was not executed).

Example for use case using this feature can be caching template block containing ContactForm7 shortcode because beside echoing HTML this plugin relies on actions to include some javascript. Using 3rd parameter you can execute all that side-effects to simulate normal environment and ensure plugin proper operation, in this case: echoing missing javascript code.

MVC themes
----------

[](#mvc-themes)

This library is perfect for MVC style themes, you can wrap all getters from "model" with closure and fetch them via Get() method, just like in last usage example. Pure simplicity: gather all data from all sources and cache them in single call.

---

Security issues
===============

[](#security-issues)

If you have found a security issue, please contact the author directly at .

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 80% 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 ~211 days

Recently: every ~248 days

Total

6

Last Release

884d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/602ff9e427232acb63fd7cd90f1051fe590d87d1c53dbc0e70acc25c811cc7b9?d=identicon)[tekod](/maintainers/tekod)

---

Top Contributors

[![tekod](https://avatars.githubusercontent.com/u/7004448?v=4)](https://github.com/tekod "tekod (16 commits)")[![fws-miroslav](https://avatars.githubusercontent.com/u/73218473?v=4)](https://github.com/fws-miroslav "fws-miroslav (4 commits)")

---

Tags

wordpressdatacachecachingwp

### Embed Badge

![Health badge](/badges/tekod-wp-cache-controller/health.svg)

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

###  Alternatives

[rtcamp/nginx-helper

Cleans nginx's fastcgi/proxy cache or redis-cache whenever a post is edited/published. Also provides cloudflare edge cache purging with Cache-Tags.

23617.1k1](/packages/rtcamp-nginx-helper)

PHPackages © 2026

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