PHPackages                             jsq/doctrine-cache-encrypter - 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. jsq/doctrine-cache-encrypter

AbandonedArchivedLibrary[Caching](/categories/caching)

jsq/doctrine-cache-encrypter
============================

An encrypting decorator for instances of Doctrine\\Common\\Cache\\Cache

0.4.0(10y ago)11.8k1Apache-2.0PHPPHP &gt;=5.5

Since Sep 4Pushed 9y ago1 watchersCompare

[ Source](https://github.com/jeskew/doctrine-cache-encrypter)[ Packagist](https://packagist.org/packages/jsq/doctrine-cache-encrypter)[ RSS](/packages/jsq-doctrine-cache-encrypter/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (3)Versions (7)Used By (1)

Doctrine Cache Encrypter
========================

[](#doctrine-cache-encrypter)

[![Build Status](https://camo.githubusercontent.com/7779188b0eefc6a638f6a98ec2ce3136bfeac89dad35eb556bee2ffeb1416e37/68747470733a2f2f7472617669732d63692e6f72672f6a65736b65772f646f637472696e652d63616368652d656e637279707465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/jeskew/doctrine-cache-encrypter)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/a7eeb4bb0691c857f8c9a0b12f87162b693205e842cd9875ba319d9dbadf2bac/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a65736b65772f646f637472696e652d63616368652d656e637279707465722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/jeskew/doctrine-cache-encrypter/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/db17ac2f50c6477aa1172bd86844431eccd82bd22cdccfc7b18a73f885a85e24/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a65736b65772f646f637472696e652d63616368652d656e637279707465722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/jeskew/doctrine-cache-encrypter/?branch=master)[![Apache 2 License](https://camo.githubusercontent.com/46136d32eabd9164ea9f4c729bae8c725959150254234b16bd11e7ee10987d34/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6a73712f646f637472696e652d63616368652d656e637279707465722e7376673f7374796c653d666c6174)](https://www.apache.org/licenses/LICENSE-2.0.html)[![Total Downloads](https://camo.githubusercontent.com/205b54989f3d356113f10ee8d79caeec67547c445a97f540e8ddce30e0e792d2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a73712f646f637472696e652d63616368652d656e637279707465722e7376673f7374796c653d666c6174)](https://packagist.org/packages/jsq/doctrine-cache-encrypter)[![Author](https://camo.githubusercontent.com/297a2017c3c5d5b0f717bf17f2713cd12b5ba24945e861cf9af88e37d6bf50ce/687474703a2f2f696d672e736869656c64732e696f2f62616467652f617574686f722d406a7265736b65772d626c75652e7376673f7374796c653d666c61742d737175617265)](https://twitter.com/jreskew)

Having to encrypt your data at rest shouldn't keep you from using the open-source tools you know and love. If you have data that needs a higher degree of security than the rest of your cache, you can store and access it via an `EncryptingDecorator`.

Caveats
-------

[](#caveats)

Encryption and decryption are both expensive operations, and frequent reads from an encrypted data store can quickly become a bottleneck in otherwise performant applications. Use encrypted caches sparingly (i.e., **do not** use an encrypting decorator around your Doctrine Annotations cache).

Usage
-----

[](#usage)

> This package provides two cache decorators, one that encrypts data using a pass phrase and one that does so with public and private keys. The implementation using a pass phrase is the more performant of the two but requires that you securely deploy a plaintext password.

First, create your Doctrine-based cache as you normally would:

```
$cache = new \Doctrine\Common\Cache\RedisCache($redisClient);
```

Second, wrap your cache with an encrypting decorator:

```
$encryptedCache = new \Jsq\Cache\PasswordEncryption\Decorator(
    $cache,
    $password,
    $cipher // optional, defaults to 'aes-256-cbc'
);
```

Then use your `$cache` and `$encryptedCache` like you normally would:

```
$cache->save('normal_cache_data', 'Totally normal!');

$encryptedCache->save('api_keys', $keys);
```

Though your regular cache and encrypted cache share a storage layer and a keyspace, they will not be able to read each other's data. The `$encryptedCache`will return `false` if asked to read unencrypted data, and the regular `$cache`will return gibberish if asked to read encrypted data.

Encrypting your cache without sharing secrets
---------------------------------------------

[](#encrypting-your-cache-without-sharing-secrets)

If you'd rather not rely on a shared password, the `EnvelopeEncryption\Decorator`can secure your sensitive cache entries using a public/private key pair.

```
$encryptedCache = new \Jsq\Cache\EnvelopeEncryption\Decorator(
    $cache,
    'file:///path/to/certificate.pem',
    'file:///path/to/private/key.pem',
    $passphrase_for_private_key_file, // optional, defaults to null
    $cipher // optional, defaults to 'aes-256-cbc'
);
```

> The certificate can be a valid x509 certificate, a path to a PEM-encoded certificate file (the path must be prefaced with `file://`), or a PEM-encoded certificate string. The private key can be a path to a PEM-encoded private key file (the path must be prefaced with `file://`), or a PEM-encoded certificate string.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity52

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

Total

5

Last Release

3729d ago

PHP version history (3 changes)0.0.1PHP &gt;=5.3

0.2.0PHP &gt;=5.4

0.4.0PHP &gt;=5.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/76a37eaa8fb7a04df094d25e1b53a908621faa9961da919f50c1c6c762ffbdfe?d=identicon)[jeskew](/maintainers/jeskew)

---

Top Contributors

[![jeskew](https://avatars.githubusercontent.com/u/705500?v=4)](https://github.com/jeskew "jeskew (28 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jsq-doctrine-cache-encrypter/health.svg)

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

###  Alternatives

[cache/cache

Library of all the php-cache adapters

2712.7M22](/packages/cache-cache)[roave/doctrine-simplecache

Doctrine Cache adapter for PSR-16 Simple Cache

551.3M1](/packages/roave-doctrine-simplecache)[chh/cache-service-provider

Provides easy to use caching for Silex applications, built on top of the doctrine/cache package

23163.0k1](/packages/chh-cache-service-provider)[tbbc/cache-bundle

Symfony Bundle - Cache abstraction and method annotations for controlling cache

3613.0k](/packages/tbbc-cache-bundle)

PHPackages © 2026

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