PHPackages                             jeremyharris/cacher - 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. jeremyharris/cacher

AbandonedArchivedCakephp-plugin[Caching](/categories/caching)

jeremyharris/cacher
===================

Cacher is a plugin for CakePHP that allows you to easily cache find results

4910.2k13[3 issues](https://github.com/jeremyharris/cacher/issues)1PHP

Since Jun 9Pushed 10y ago4 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (1)

[![build status](https://camo.githubusercontent.com/eb39613e77c63c9140bd7a173dfaa2afbfa069086815c96ee95960644b2fd4a2/68747470733a2f2f7472617669732d63692e6f72672f6a6572656d796861727269732f6361636865722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/jeremyharris/cacher)

Cacher
======

[](#cacher)

Cacher is a plugin for CakePHP that allows you to easily cache find results. While most solutions for caching queries force you to overwrite `Model::find()`in your AppModel, Cacher only requires adding a behavior to your model.

Have settings that hardly change? Have a database list of states or something that never change but you still want them in the db? Just like caching your results? Use Cacher!

Requirements
------------

[](#requirements)

- CakePHP &gt;= 2.0.x (check tags for older versions of CakePHP)

Usage
-----

[](#usage)

```
var $actsAs = array(
    'Cacher.Cache'
);

```

By default, Cacher uses the 'default' cache configuration in your core.php file. If you want to use a different configuration, just pass it in the 'config' key.

```
var $actsAs = array(
    'Cacher.Cache' => array(
        'config' => 'myCacheConfiguration'
    )
);

```

> It's best to place Cacher last on your list of behaviors so the query Cacher looks for reflects the changes the previous behaviors might have made.

### Options that you can pass:

[](#options-that-you-can-pass)

- `config` The name of an existing Cache configuration to duplicate (default 'default')
- `clearOnSave` Whether or not to delete the cache on saves (default `true`)
- `clearOnDelete` Whether or not to delete the cache on deletes (default `true`)
- `auto` Automatically cache (default `false`)
- `gzip` Automatically compress/decompress cached data (default `false`)

### Using Cacher with `Model::find()`, `Controller::paginate()`, etc.

[](#using-cacher-with-modelfind-controllerpaginate-etc)

If you set auto to false, you can pass a `'cacher'` key in your query that is either `true` to cache the results, `false` to not cache it, or a valid `strtotime()` string to set a duration for that specific call.

```
// cache the results of this query for a day
$this->Post->find('all', array(
	  'conditions' => array('Post.name LIKE' => '%awesome%'),
	  'cacher' => '+1 day'
));
// don't cache the results of this query at all
$this->Post->find('all', array(
	  'conditions' => array('Post.name LIKE' => '%lame%'),
	  'cacher' => false
));
// cache using the default settings even if auto = false
$this->Post->find('all', array(
	  'conditions' => array('Post.name LIKE' => '%okay i guess%'),
	  'cacher' => true
));

```

How it works
------------

[](#how-it-works)

Cacher intercepts any find query and temporarily changes the datasource to one that handle's checking the cache..

You can always disable Cacher by using `Behavior::detach()` or `Behavior::disable()`.

Features
--------

[](#features)

- Quick and easy caching by just attaching the behavior to a model
- Clear cache for a specific model on the fly using `$this->Post->clearCache()`
- Clear a specific query by passing the conditions to `clearCache()`

Todo
----

[](#todo)

- I'd like to add other caching functionality to make it more all-in-one
- Would like to make the Cache datasource a reuseable, standalone datasource

Notes
-----

[](#notes)

Since Cacher caches the entire results of a find, some cache can become stale before it's parent does. For example, let's say you cache the results of finding a post and containing all comments. If a comment is deleted and the cache remains, it will show that comment. The only way to remove it would be to invalidate the original query on the Post model. Ideas around this have been passed around between some developers and I'm still trying to figure out the best way to handle this.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity37

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 76.5% 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://www.gravatar.com/avatar/59d2777f8c20cea49840f628d5b571f4d035e7145284c02799d4dafd8d6e156a?d=identicon)[jmcneese](/maintainers/jmcneese)

---

Top Contributors

[![jeremyharris](https://avatars.githubusercontent.com/u/184903?v=4)](https://github.com/jeremyharris "jeremyharris (13 commits)")[![joshcarlson](https://avatars.githubusercontent.com/u/931528?v=4)](https://github.com/joshcarlson "joshcarlson (4 commits)")

### Embed Badge

![Health badge](/badges/jeremyharris-cacher/health.svg)

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

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