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

Abandoned → cacheCakephp-plugin[Caching](/categories/caching)

oanhnn/cache
============

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

1.1(11y ago)0644PHP

Since Dec 13Pushed 11y agoCompare

[ Source](https://github.com/rikkeisoft/cache)[ Packagist](https://packagist.org/packages/oanhnn/cache)[ Docs](https://github.com/oanhnn/cache)[ RSS](/packages/oanhnn-cache/feed)WikiDiscussions master Synced 2mo ago

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

Cache
=====

[](#cache)

Cache 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, Cache 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 Cache!

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

[](#requirements)

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

Install
-------

[](#install)

Usage
-----

[](#usage)

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

By default, Cache 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 array Using Behavior
     */
    public $actsAs = array(
        'Cache.Cached' => array(
            'config' => '_cake_queries_',
            'map' => '_cake_queries_map_',
            'clearOnDelete' => true,
            'clearOnSave' => true,
            'auto' => true,
            'gzip' => false,
        ),
    );
```

> It's best to place Cache 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')
- `map` The name of an existing Cache configuration to duplicate (default 'default'), for 'map of cache keys'
- `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 Cache with `Model::find()`, `Controller::paginate()`, etc.

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

If you set auto to false, you can pass a `'cache'` key in your query that is either `true` to cache the results, `false` to not cache it, or array options to overwrite default settings for that specific call.

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

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

[](#how-it-works)

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

You can always disable Cache 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()`

Task lists
----------

[](#task-lists)

- Write test scripts
- Write how to install

Thank for
---------

[](#thank-for)

- [Jeremy Harris](mailto:jeremy@someguyjeremy.com) with [Cacher](https://github.com/jeremyharris/cacher)

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity64

Established project with proven stability

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

Total

2

Last Release

4280d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b32dfbbbf603d0317f2ab7ab33c7c7611e90f6701c5c84f07a8b537aa84e83f7?d=identicon)[oanhnn](/maintainers/oanhnn)

---

Tags

plugincakephpcache

### Embed Badge

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

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

###  Alternatives

[wp-media/wp-rocket

Performance optimization plugin for WordPress

7431.3M3](/packages/wp-media-wp-rocket)[rtcamp/nginx-helper

Cleans nginx's fastcgi/proxy cache or redis-cache whenever a post is edited/published. Also provides cloudflare edge cache purging with Cache-Tags.

23817.0k1](/packages/rtcamp-nginx-helper)

PHPackages © 2026

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