PHPackages                             tjm/cache - 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. tjm/cache

ActiveLibrary[Caching](/categories/caching)

tjm/cache
=========

A simple filesystem cache implementation for storing PHP data

00PHP

Since Aug 28Pushed 1y ago1 watchersCompare

[ Source](https://github.com/tobymackenzie/cache.php)[ Packagist](https://packagist.org/packages/tjm/cache)[ RSS](/packages/tjm-cache/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

PHP Cache
=========

[](#php-cache)

A simple filesystem cache implementation for storing PHP data. Note that this is a very early implementation and is almost definitely going to change significantly. I want to make it psr-6 / psr-16 compatible, but still allow the calculator / validator functionality if desired.

Use
---

[](#use)

### `TJM\Cache\Pool` class

[](#tjmcachepool-class)

#### `__construct($path = '/tmp/tjm-cache')`

[](#__constructpath--tmptjm-cache)

#### `get(string $key, callable $calculator = null, int|bool|callable $validator = true)`

[](#getstring-key-callable-calculator--null-intboolcallable-validator--true)

- $key: string reference of item, used to store
- $calculator: callable, returns cache value. run only if cache is invalidated, then stored in cache
- $validator: validate cache.
    - false: always invalid
    - true: invalid if already in cache
    - int: number of seconds since creation to consider stale
    - callable: return boolean of whether item is valid

Returns cached or calculated value.

### example

[](#example)

```
$cache = new TJM\Cache\Pool();
$items = $cache->get('items', function() use($db){
	return $db->getItems();
}, 1200);
```

This will get items from `$db` on first run. If next run is less than 1200 seconds later, it will then get them from the cache. Once 1200 seconds have elapsed, the next run will get the from `$db` again.

###  Health Score

13

—

LowBetter than 1% of packages

Maintenance28

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity17

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/731711?v=4)[Toby Mackenzie](/maintainers/tobymackenzie)[@tobymackenzie](https://github.com/tobymackenzie)

---

Top Contributors

[![tobymackenzie](https://avatars.githubusercontent.com/u/731711?v=4)](https://github.com/tobymackenzie "tobymackenzie (3 commits)")

### Embed Badge

![Health badge](/badges/tjm-cache/health.svg)

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

###  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)
