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

ActiveLibrary[Caching](/categories/caching)

byjg/cache-engine
=================

A powerful, versatile cache implementation providing both PSR-6 and PSR-16 interfaces with support for multiple storage drivers.

6.0.1(4mo ago)1168.0k↓24.8%4[1 issues](https://github.com/byjg/php-cache-engine/issues)8MITPHPPHP &gt;=8.3 &lt;8.6CI failing

Since Jul 21Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/byjg/php-cache-engine)[ Packagist](https://packagist.org/packages/byjg/cache-engine)[ GitHub Sponsors](https://github.com/byjg)[ RSS](/packages/byjg-cache-engine/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (6)Versions (30)Used By (8)

   sidebar\_key cache-engine   tags    php

 databases

 cache

    Cache Engine
============

[](#cache-engine)

A powerful, versatile cache implementation providing both PSR-6 and PSR-16 interfaces with support for multiple storage drivers.

[![Sponsor](https://camo.githubusercontent.com/fab14b7f7f475072ada0473f193d6f322561fd4a2958e0cc89910d053347cf27/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53706f6e736f722d2532336561346161613f6c6f676f3d67697468756273706f6e736f7273266c6f676f436f6c6f723d7768697465266c6162656c436f6c6f723d306431313137)](https://github.com/sponsors/byjg)[![Build Status](https://github.com/byjg/php-cache-engine/actions/workflows/phpunit.yml/badge.svg?branch=master)](https://github.com/byjg/php-cache-engine/actions/workflows/phpunit.yml)[![Opensource ByJG](https://camo.githubusercontent.com/425c1bbccc0f292bf4d20569ae74a6b2e384fd648f1af8911bc61de9a8dcfc0b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6f70656e736f757263652d62796a672d737563636573732e737667)](http://opensource.byjg.com)[![GitHub source](https://camo.githubusercontent.com/88e61eb211719144efdd570290a0456b6e13099c2df8d973f1bb43fe33bf0039/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4769746875622d736f757263652d696e666f726d6174696f6e616c3f6c6f676f3d676974687562)](https://github.com/byjg/php-cache-engine/)[![GitHub license](https://camo.githubusercontent.com/c83b0e723cba61df69e5df1e9f3681bf730766b5b164bac2a1b43279b32526c5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f62796a672f7068702d63616368652d656e67696e652e737667)](https://opensource.byjg.com/opensource/licensing.html)[![GitHub release](https://camo.githubusercontent.com/9c042c64fe0d195c716238f76573d5b9e10fe83000ef507e02c29318561f2397/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f62796a672f7068702d63616368652d656e67696e652e737667)](https://github.com/byjg/php-cache-engine/releases/)

Key Features
------------

[](#key-features)

- **PSR-16 Simple Cache interface** - Simple, straightforward caching API
- **PSR-6 Cache Pool interface** - More verbose caching with fine-grained control
- **Multiple storage backends** - Choose from memory, file system, Redis, Memcached and more
- **Atomic operations** - Support for increment, decrement and add operations in compatible engines
- **Garbage collection** - Automatic cleanup of expired items
- **PSR-11 container support** - Retrieve cache keys via dependency container
- **Logging capabilities** - PSR-3 compatible logging of cache operations

Quick Start
-----------

[](#quick-start)

```
composer require "byjg/cache-engine"
```

```
// PSR-16 Simple Cache
$cache = new \ByJG\Cache\Psr16\FileSystemCacheEngine();
$cache->set('key', 'value', 3600); // Cache for 1 hour
$value = $cache->get('key');

// PSR-6 Cache Pool
$pool = \ByJG\Cache\Factory::createFilePool();
$item = $pool->getItem('key');
if (!$item->isHit()) {
    $item->set('value');
    $item->expiresAfter(3600);
    $pool->save($item);
}
$value = $item->get();
```

Documentation
-------------

[](#documentation)

### Getting Started

[](#getting-started)

- [PSR-16 Simple Cache Usage](docs/basic-usage-psr16-simplecache.md)
- [PSR-6 Cache Pool Usage](docs/basic-usage-psr6-cachepool.md)

### Available Cache Engines

[](#available-cache-engines)

EngineDescription[NoCacheEngine](docs/class-no-cache-engine.md)No-op engine for disabling cache without code changes[ArrayCacheEngine](docs/class-array-cache-engine.md)In-memory array cache (non-persistent between requests)[FileSystemCacheEngine](docs/class-filesystem-cache-engine.md)File system based caching[MemcachedEngine](docs/class-memcached-engine.md)Memcached distributed caching[RedisCacheEngine](docs/class-redis-cache-engine.md)Redis-based caching[SessionCacheEngine](docs/class-session-cache-engine.md)PHP session-based caching[TmpfsCacheEngine](docs/class-tmpfs-cache-engine.md)Tmpfs-based caching[ShmopCacheEngine](docs/class-shmop-cache-engine.md)Shared memory caching (deprecated)[KeyValueCacheEngine](https://github.com/byjg/php-anydataset-nosql)S3-Like or CloudflareKV storage (separate package)### Advanced Features

[](#advanced-features)

- [Atomic Operations](docs/atomic-operations.md)
- [Garbage Collection](docs/garbage-collection.md)
- [Logging](docs/setup-log-handler.md)
- [PSR-11 Container Usage](docs/psr11-usage.md)

Running Unit Tests
------------------

[](#running-unit-tests)

```
vendor/bin/phpunit --stderr

```

**Note:** The `--stderr` parameter is required for SessionCacheEngine tests to run properly.

Dependencies
------------

[](#dependencies)

 ```
flowchart TD
    byjg/cache-engine --> psr/cache
    byjg/cache-engine --> psr/log
    byjg/cache-engine --> psr/simple-cache
    byjg/cache-engine --> psr/container
```

      Loading ---

[Open source ByJG](http://opensource.byjg.com)

###  Health Score

61

—

FairBetter than 98% of packages

Maintenance76

Regular maintenance activity

Popularity39

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity91

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 98.9% 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 ~143 days

Recently: every ~45 days

Total

28

Last Release

132d ago

Major Versions

1.0.4 → 2.0.02016-08-10

2.0.0 → 3.0.02017-02-14

3.0.0 → 4.0.02017-05-27

4.9.3 → 5.0.02024-10-27

5.0.x-dev → 6.0.02025-11-21

PHP version history (5 changes)1.0.0PHP &gt;=5.4.0

4.0.2PHP &gt;=5.6.0

4.9.1PHP &gt;=7.4

5.0.0PHP &gt;=8.1 &lt;8.4

6.0.0PHP &gt;=8.3 &lt;8.6

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/981924?v=4)[Joao Gilberto Magalhaes](/maintainers/byjg)[@byjg](https://github.com/byjg)

---

Top Contributors

[![byjg](https://avatars.githubusercontent.com/u/981924?v=4)](https://github.com/byjg "byjg (172 commits)")[![farmerau](https://avatars.githubusercontent.com/u/5827236?v=4)](https://github.com/farmerau "farmerau (1 commits)")[![techhead](https://avatars.githubusercontent.com/u/311112?v=4)](https://github.com/techhead "techhead (1 commits)")

---

Tags

cachecachepoolmemcachedphppsr-16psr-6redisshared-memory

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[symfony/symfony

The Symfony PHP framework

31.4k87.2M2.2k](/packages/symfony-symfony)[laravel/framework

The Laravel Framework.

34.8k543.8M20.1k](/packages/laravel-framework)[symfony/cache

Provides extended PSR-6, PSR-16 (and tags) implementations

4.2k373.5M3.3k](/packages/symfony-cache)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[cakephp/cakephp

The CakePHP framework

8.9k19.5M1.8k](/packages/cakephp-cakephp)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k43](/packages/civicrm-civicrm-core)

PHPackages © 2026

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