PHPackages                             jnilla/joomla-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. jnilla/joomla-cache-helper

ActiveLibrary[Caching](/categories/caching)

jnilla/joomla-cache-helper
==========================

Use Joomla cache support fast and easy

v0.0.7(4y ago)0281MITPHP

Since Oct 15Pushed 4y ago1 watchersCompare

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

READMEChangelog (8)DependenciesVersions (9)Used By (0)

joomla-cache-helper
===================

[](#joomla-cache-helper)

A Joomla cache helper for easier usage.

This helper is build on top of the native Joomla cache support. We implemented a simpler API and added few extra features to make the helper practical.

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

[](#installation)

Install using Composer:

```
$ composer require jnilla/joomla-cache-helper

```

Load the library using the Composer autoloader:

```
require('vendor/autoload.php');

```

Basic Usage
-----------

[](#basic-usage)

Declaration:

```
use Jnilla\Joomla\CacheHelper as CacheHelper;

```

Store data to cache:

```
CacheHelper::set('idHere', 'groupNameHere', 'Some string data here');

```

Get data from cache:

```
$cache = CacheHelper::get('idHere', 'groupNameHere');

// $cache var dump
array (size=4)
  'isValid' => boolean true
  'isUpdating' => boolean false
  'isTimeout' => boolean false
  'data' => string 'Some string data here' (length=0)

```

The proxy method:

```
$cache = CacheHelper::proxy(
	'idHere', // Cache Id
	'groupNameHere', // Cache Group
	function(){return 'Some string data here';}, // Callback that returns the data to cache
	6, // Cache Lifetime
	15 // Wait if updating
);

// $cache var dump
array (size=4)
  'isValid' => boolean true
  'isUpdating' => boolean false
  'isTimeout' => boolean false
  'data' => string 'Some string data here' (length=0)

```

If the flag `isValid` is `true` you can use the cache item data safely.

The most practical way to work with this library is using the `proxy` method.

This methods works as 2 in 1 intermediary that get and updates the cache item automatically if needed.

How it works:

- If the cache item is not stale the method returns the cache item.
- If the cache item is stale the method executes de callback, store the result in the cache and returns the updated cache item.

Example with remote data:

```
$cache = CacheHelper::callback(
	'idHere', // Cache Id
	'groupNameHere', // Cache Group
	function(){return file_get_contents('https://jsonplaceholder.typicode.com/todos');}, // Callback that returns the data to cache
	6, // Cache Lifetime
	15 // Wait if updating
);

// $cache var dump
array (size=4)
  'isValid' => boolean true
  'isUpdating' => boolean false
  'isTimeout' => boolean false
  'data' => string '{some JSON code from that source}' (length=0)

```

The lifetime is the time before a cache item is considered stale and needs to be updated.

It's useful to know that we can use the `$lifetime` argument as a request rate limit mechanism using a formula like this 60 seconds / number\_of\_request = lifetime. Example: For a rate limit of 10 requests per minute use: 60 seconds / 10 requests = 10 seconds.

Wait Mechanism
--------------

[](#wait-mechanism)

There is a wait mechanism that is useful for certain cases of use.

The methods `get` and `proxy` share the following argument:

- @param integer **$wait:** Time in seconds to force current operation to wait if the cache item is updating.

**Case 1:**

5 users request remote data using the `proxy` method at the same time for the first time and the `$wait` is not `0`.

The first user to use the `proxy` method triggers the `isUpdading` flag and everyone gets to wait for the remote fetch operation to finish. After this, everyone gets the same data at the same time.

**Case 2:**

5 users request remote data using the `proxy` method at the same time for the first time and the `$wait` is `0`.

The first user to use the `proxy` method triggers the `isUpdading` flag and only this user gets to wait for the remote fetch operation to finish. Everyone else gets an empty cache item at the same time.

This case is useful if you don't want to lock everyone on a waiting period the firt time the remote data is requested.

This behavior helps to aliviate server RAM usage because requests/CPU Threads live shorter.

**Case 3:**

5 users request remote data using the `proxy` method at the same time for the first time and the `$wait` is not `0`, but the remote operation takes too long.

The first user to use the `proxy` method triggers the `isUpdading` flag and everyone gets to wait. If `$wait` time is reached the `isUpdading` flag is set to `false`, the `isTimeout` flag is set to `true` and everyone gets an empty cache item at the same time.

This prevents too long or infinite wait times for eveyone.

License
-------

[](#license)

This project is under the MIT License.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity49

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 ~44 days

Recently: every ~1 days

Total

8

Last Release

1722d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/57fd06b6b69b2a42631897f0c2b340457fac86624597b12df906690c64831076?d=identicon)[jnilla](/maintainers/jnilla)

---

Top Contributors

[![jnilla](https://avatars.githubusercontent.com/u/965514?v=4)](https://github.com/jnilla "jnilla (24 commits)")

---

Tags

helpercachejoomla

### Embed Badge

![Health badge](/badges/jnilla-joomla-cache-helper/health.svg)

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

###  Alternatives

[psr/simple-cache

Common interfaces for simple caching

8.1k727.3M2.1k](/packages/psr-simple-cache)[psr/cache

Common interface for caching libraries

5.2k686.9M1.3k](/packages/psr-cache)[react/cache

Async, Promise-based cache interface for ReactPHP

444112.4M40](/packages/react-cache)[dragon-code/laravel-cache

An improved interface for working with cache

6844.8k9](/packages/dragon-code-laravel-cache)[beste/in-memory-cache

A PSR-6 In-Memory cache that can be used as a fallback implementation and/or in tests.

2512.2M6](/packages/beste-in-memory-cache)[anahkiasen/flatten

A package for the Illuminate framework that flattens pages to plain HTML

33313.0k](/packages/anahkiasen-flatten)

PHPackages © 2026

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