cache/encryption-cache

Adds encryption support to your PSR-6 cache implementation

Maintainers

Package info

github.com/php-cache/encryption-cache

Homepage

pkg:composer/cache/encryption-cache

Transparency log

Statistics

Installs: 11 223

Dependents: 0

Suggesters: 0

Stars: 1

2.0.2 2026-08-18 20:48 UTC

This package is auto-updated.

Last update: 2026-08-18 21:00:35 UTC


README

Latest Stable Version Coverage Software License

This package encrypts values stored through a taggable PSR-6 cache pool. Encryption adds CPU and storage overhead, so use it only when cached values need protection at rest.

Installation

composer require cache/encryption-cache:^2.0

Usage

use Cache\Adapter\PHPArray\ArrayCachePool;
use Cache\Encryption\EncryptedCachePool;
use Defuse\Crypto\Key;

$key = Key::createNewRandomKey();
$pool = new EncryptedCachePool(new ArrayCachePool(), $key);

$item = $pool->getItem('account.42');
$item->set(['email' => 'user@example.com']);
$pool->save($item);

The wrapped pool must implement TaggableCacheItemPoolInterface. Persist the encryption key outside the cache and load the same key for every request.

Contributing

Send pull requests to the main repository. Report issues on the GitHub issue tracker.