PHPackages                             lioshi/wonder-cache-bundle - 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. lioshi/wonder-cache-bundle

ActiveSymfony-bundle[Caching](/categories/caching)

lioshi/wonder-cache-bundle
==========================

A full response cache with automatic invalidation.

420PHP

Since Jun 26Pushed 6y ago2 watchersCompare

[ Source](https://github.com/lioshi/WonderCacheBundle)[ Packagist](https://packagist.org/packages/lioshi/wonder-cache-bundle)[ RSS](/packages/lioshi-wonder-cache-bundle/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

lioshi WonderCacheBundle
========================

[](#lioshi-wondercachebundle)

This [Symfony 2](http://symfony.com) bundle provides a full response cache with automatic invalidation via [doctrine](http://www.doctrine-project.org/) events:

- just one service's call to manage cache of an action
- no wasted time setting up a cache invalidation system

[![knpbundles.com](https://camo.githubusercontent.com/61a3407f8fe41afd47708916572969af53e676ac8ec03dbd45da819d14efaf38/687474703a2f2f6b6e7062756e646c65732e636f6d2f6c696f7368692f576f6e646572436163686542756e646c652f62616467652d73686f7274)](http://knpbundles.com/lioshi/WonderCacheBundle)

How works **WonderCache** [![screenshot](https://camo.githubusercontent.com/f496235d926fadb57165481e28335ec2f6d3ac1196798b3fd626473307a062c8/68747470733a2f2f7261772e6769746875622e636f6d2f6c696f7368692f576f6e646572436163686542756e646c652f6d61737465722f5265736f75726365732f696d616765732f69636f6e5f2e706e67)](https://camo.githubusercontent.com/f496235d926fadb57165481e28335ec2f6d3ac1196798b3fd626473307a062c8/68747470733a2f2f7261772e6769746875622e636f6d2f6c696f7368692f576f6e646572436163686542756e646c652f6d61737465722f5265736f75726365732f696d616765732f69636f6e5f2e706e67)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

[](#how-works-wondercache-)

[![screenshot](https://camo.githubusercontent.com/c237221eb95a2c9b93f6329067b7b095e14735e8039a71f269fbb770021a25f5/68747470733a2f2f7261772e6769746875622e636f6d2f6c696f7368692f576f6e646572436163686542756e646c652f6d61737465722f5265736f75726365732f696d616765732f776f6e64657263616368655f776f726b666c6f772e706e67)](https://camo.githubusercontent.com/c237221eb95a2c9b93f6329067b7b095e14735e8039a71f269fbb770021a25f5/68747470733a2f2f7261772e6769746875622e636f6d2f6c696f7368692f576f6e646572436163686542756e646c652f6d61737465722f5265736f75726365732f696d616765732f776f6e64657263616368655f776f726b666c6f772e706e67)

**WonderCache** is there at request and bypasses all framework. As a proxy. But WonderCache knows when invalidate its cache.

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

[](#requirements)

- PHP 5.3.x or more
- php5-memcached 2.x

Installation
------------

[](#installation)

Use [Composer](http://getcomposer.org/) to install to install WonderCacheBundle with Composer just add the following to your *composer.json* file:

```
{
    require: {
        "lioshi/wonder-cache-bundle": "dev-master",
        ...
    }
}

```

The next thing you should do is install the bundle by executing the following command:

```
php composer.phar update lioshi/wonder-cache-bundle

```

Finally, add the bundle to the registerBundles function of the AppKernel class in the *app/AppKernel.php* file:

```
public function registerBundles()
{
    $bundles = array(
        ...
        new Lioshi\WonderCacheBundle\LioshiWonderCacheBundle(),
        ...
    );

```

Configure the bundle by adding the following to *app/config/config.yml*:

```
    lioshi_wonder_cache:
        activated: true
        memcached_response:
            hosts:
                - { dsn: localhost, port: 11211 }
```

### Dependencies

[](#dependencies)

> in Debian based systems

```
apt-get install memcached php5-memcached

```

> in Centos based systems

```
yum install php-pecl-memcached

```

Do not forget to restart you web server after adding the Memcache module.

Commands
--------

[](#commands)

The `wondercache:clear` command delete all cached items and `wondercache:list` command can list all cache's keys and can display content of a choosen key.

Full configuration
------------------

[](#full-configuration)

```
    lioshi_wonder_cache:
        activated: true
        included_headers_keys:
            - email                     # Specify list of header's keys to include in url. Add only header's keys if page content return depends of. Or put ALL for all header's key
        memcached_response:
            hosts:
                - { dsn: localhost, port: 11211, weight: 60 }
                - { dsn: localhost, port: 11212, weight: 30 }
            options:
                compression: true
                serializer: 'json'
                prefix_key: ""
                hash: default
                distribution: 'consistent'
                libketama_compatible: true
                buffer_writes: true
                binary_protocol: true
                no_block: true
                tcp_nodelay: false
                socket_send_size: 4096
                socket_recv_size: 4096
                connect_timeout: 1000
                retry_timeout: 0
                send_timeout: 0
                recv_timeout: 0
                poll_timeout: 1000
                cache_lookups: false
                server_failure_limit: 0
```

Usage
-----

[](#usage)

Into a controller you can run() **WonderCache** and specified optionnaly entities which are linked to the controller response. The following exemple means that the controller's response depends on (or is linked to):

- 3 packs with ids 1, 65 and 988
- 2 exports with ids 65 and 22
- all cars And it expires before 3600s (by default duration is 0:infinite)

Exemple's code for a controller:

```
    $this->container->get('wonder.cache')
        ->run()
        ->addLinkedEntities(
            array(
                'Me\MyBundle\Entity\Pack' => array(1,65,988),
                'Me\MyBundle\Entity\Export' => array(65,22),
                'Me\MyBundle\Entity\Cars' => array()
            )
        )
        ->addDuration(3600)
    ;

```

Cache invalidation system
-------------------------

[](#cache-invalidation-system)

To see cache invalidation logs, just create file /tmp/wcInvalidationCache.log in your server.

```
touch /tmp/wcInvalidationCache.log

```

It's a roll log, its weight never up to 1M bytes.

Profiler's informations
-----------------------

[](#profilers-informations)

> With symfony toolbar you can follow how **WonderCache** performs. If there's some error or warning:

[![screenshot](https://camo.githubusercontent.com/084f9fb5cc8bd729c116031a30fd10001c52cbe0f64403a9f939204854b2df22/68747470733a2f2f7261772e6769746875622e636f6d2f6c696f7368692f576f6e646572436163686542756e646c652f6d61737465722f5265736f75726365732f696d616765732f776f6e64657263616368655f746f6f6c6261725f6572726f72732e706e67)](https://camo.githubusercontent.com/084f9fb5cc8bd729c116031a30fd10001c52cbe0f64403a9f939204854b2df22/68747470733a2f2f7261772e6769746875622e636f6d2f6c696f7368692f576f6e646572436163686542756e646c652f6d61737465722f5265736f75726365732f696d616765732f776f6e64657263616368655f746f6f6c6261725f6572726f72732e706e67)

> If all is good...

[![screenshot](https://camo.githubusercontent.com/20a62001166b88abf06424879085007fcb6d4f52d52f2898bbca9f5600c35d3b/68747470733a2f2f7261772e6769746875622e636f6d2f6c696f7368692f576f6e646572436163686542756e646c652f6d61737465722f5265736f75726365732f696d616765732f776f6e64657263616368655f746f6f6c6261725f696e666f732e706e67)](https://camo.githubusercontent.com/20a62001166b88abf06424879085007fcb6d4f52d52f2898bbca9f5600c35d3b/68747470733a2f2f7261772e6769746875622e636f6d2f6c696f7368692f576f6e646572436163686542756e646c652f6d61737465722f5265736f75726365732f696d616765732f776f6e64657263616368655f746f6f6c6261725f696e666f732e706e67)

> ... you can see more informations about how **WonderCache** save your time:

[![screenshot](https://camo.githubusercontent.com/876ccd84e3dd7c9002871b2a88752170fae64622899458e5cde0586804f7ee3f/68747470733a2f2f7261772e6769746875622e636f6d2f6c696f7368692f576f6e646572436163686542756e646c652f6d61737465722f5265736f75726365732f696d616765732f776f6e64657263616368655f70726f66696c65725f696e666f732e706e67)](https://camo.githubusercontent.com/876ccd84e3dd7c9002871b2a88752170fae64622899458e5cde0586804f7ee3f/68747470733a2f2f7261772e6769746875622e636f6d2f6c696f7368692f576f6e646572436163686542756e646c652f6d61737465722f5265736f75726365732f696d616765732f776f6e64657263616368655f70726f66696c65725f696e666f732e706e67)

Credits
-------

[](#credits)

Inspired by :

- DependencyInjection/Configuration.php
- Command/ClearCommand.php

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 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/d030d4c0748037e060a201be6f282a9e4a03f1eaa60cf391e24703b4f2aa4199?d=identicon)[lioshi](/maintainers/lioshi)

---

Top Contributors

[![lioshi](https://avatars.githubusercontent.com/u/1125136?v=4)](https://github.com/lioshi "lioshi (113 commits)")

### Embed Badge

![Health badge](/badges/lioshi-wonder-cache-bundle/health.svg)

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

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