PHPackages                             thefuriouscoder/propel2-data-cache-behavior - 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. [Database &amp; ORM](/categories/database)
4. /
5. thefuriouscoder/propel2-data-cache-behavior

ActivePropel-behavior[Database &amp; ORM](/categories/database)

thefuriouscoder/propel2-data-cache-behavior
===========================================

A Propel ORM behavior that provide auto data caching for model and collections. Based on snakano/propel-data-cache-behavior

417.5k↓50%5[1 issues](https://github.com/thefuriouscoder/propel2-data-cache-behavior/issues)PHP

Since Nov 5Pushed 10y ago1 watchersCompare

[ Source](https://github.com/thefuriouscoder/propel2-data-cache-behavior)[ Packagist](https://packagist.org/packages/thefuriouscoder/propel2-data-cache-behavior)[ RSS](/packages/thefuriouscoder-propel2-data-cache-behavior/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Data Cache Behavior for Propel2
===============================

[](#data-cache-behavior-for-propel2)

[![Build Status](https://camo.githubusercontent.com/722da003928b68589a225bf4763a5017500c24655368c745d44a301a0da81491/68747470733a2f2f7472617669732d63692e6f72672f534e616b616e6f2f50726f70656c4461746143616368654265686176696f722e706e67)](https://travis-ci.org/SNakano/PropelDataCacheBehavior)[![Latest Stable Version](https://camo.githubusercontent.com/98fd12e61a7011d265d79397588e94f1d3095570aa494203a2977386f31b727c/68747470733a2f2f706f7365722e707567782e6f72672f746865667572696f7573636f6465722f70726f70656c322d646174612d63616368652d6265686176696f722f762f737461626c652e706e67)](https://packagist.org/packages/thefuriouscoder/propel2-data-cache-behavior)[![Total Downloads](https://camo.githubusercontent.com/2f32a6caf5b33001161e3bf96f403ccc5684fb82fe30b4250cd6b38edcd0c48d/68747470733a2f2f706f7365722e707567782e6f72672f746865667572696f7573636f6465722f70726f70656c322d646174612d63616368652d6265686176696f722f646f776e6c6f6164732e706e67)](https://packagist.org/packages/thefuriouscoder/propel2-data-cache-behavior)

A Propel ORM behavior that provide auto data caching to your model. Based on Propel 1.6 work of [SNakano](https://github.com/SNakano/PropelDataCacheBehavior).

- support caching system APC, memcached and Redis (via [DoctrineCache](https://github.com/doctrine/cache))
- auto caching and auto flush.

#### What's the difference with Query Cache Behavior

[](#whats-the-difference-with-query-cache-behavior)

[Query Cache Behavior](http://propelorm.org/behaviors/query-cache.html) is caching transformation of a query object (caching SQL code). This Behavior is caching the results of database. (caching result data)

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

[](#requirements)

- PHP &gt;= 5.3
- Propel &gt;= 2.0.0
- [DoctrineCacheFactory](https://github.com/thefuriouscoder/doctrine-cache-factory)

Install
-------

[](#install)

### Composer

[](#composer)

Add a dependency on `thefuriouscoder/propel2-data-cache-behavior` to your project's `composer.json` file.

```
{
    "require": {
        "thefuriouscoder/propel2-data-cache-behavior": "dev-master"
    }
}
```

Configuration
-------------

[](#configuration)

### schema.xml

[](#schemaxml)

```

```

### Initialize the Cache Store.

[](#initialize-the-cache-store)

Add the following configuration code to your project bootstraping file depending on the storage you are goinng to use.

### Using Memcached (php5-memcached extension needed)

[](#using-memcached-php5-memcached-extension-needed)

```
// configure memcached setting.
TFC\Cache\DoctrineCacheFactory::setOption(
    array(
        'storage'     => 'memcached',
        'prefix'      => 'rlyeh',
        'default_ttl' => 3600,
        'servers'     => array(
            array('server1', 11211, 20),
            array('server2', 11211, 80)
        )
    )
);
```

### Using APC

[](#using-apc)

```
// configure APC setting.
TFC\Cache\DoctrineCacheFactory::setOption(
    array(
        'storage'     => 'apc',
        'default_ttl' => 3600
    )
);
```

### Using Redis

[](#using-redis)

```
// configure Redis setting.
TFC\Cache\DoctrineCacheFactory::setOption(
    array(
        'storage'     => 'redis',
        'prefix'      => 'rlyeh',
        'host         => '127.0.0.1',
        'port'        => 6379,
        'default_ttl' => 3600
    )
);
```

### Basic usage

[](#basic-usage)

```
$title = 'Cthulhu Mythos';
BookQuery::create()
    ->filterByTitle($title)
    ->findOne(); // from Database

BookQuery::create()
    ->filterByTitle($title)
    ->findOne(); // from caching system
```

### Disable cache

[](#disable-cache)

```
$title = 'Cthulhu Mythos';
BookQuery::create()
    ->setCacheDisable()  // disable cache
    ->filterByTitle($title)
    ->findOne();
```

- setCacheEnable()
- setCacheDisable()
- isCacheEnable()
- setLifetime($ttl)

### When cache delete?

[](#when-cache-delete)

```
$book = new Book;
$book->setId(1);
$book->setTitle("Cthulhu Myhtos");
$book->save();  // purge cache.
```

- expire cache lifetime.
- call `save()` method.
- call `delete()` method.
- call `BookQuery::doDeleteAll()` method.
- call `BookQuery::purgeCache()` method.

### Manually delete cache.

[](#manually-delete-cache)

```
$title = 'Cthulhu Mythos';
$query = BookQuery::create();
$book  = $query->filterByTitle($title)->findOne();
$cacheKey = $query->getCacheKey(); // get cache key.

BookPeer::cacheDelete($cacheKey);  // delete cache by key.
```

License
-------

[](#license)

MIT License

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance15

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/2ed65a4ed61955b93b80232fc79b71da578bf69e06c172bf6d28a663981c7054?d=identicon)[thefuriouscoder](/maintainers/thefuriouscoder)

---

Top Contributors

[![thefuriouscoder](https://avatars.githubusercontent.com/u/944027?v=4)](https://github.com/thefuriouscoder "thefuriouscoder (8 commits)")

### Embed Badge

![Health badge](/badges/thefuriouscoder-propel2-data-cache-behavior/health.svg)

```
[![Health](https://phpackages.com/badges/thefuriouscoder-propel2-data-cache-behavior/health.svg)](https://phpackages.com/packages/thefuriouscoder-propel2-data-cache-behavior)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90440.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)[wildside/userstamps

Laravel Userstamps provides an Eloquent trait which automatically maintains `created\_by` and `updated\_by` columns on your model, populated by the currently authenticated user in your application.

7511.7M13](/packages/wildside-userstamps)

PHPackages © 2026

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