PHPackages                             solilokiam/httprediscache - 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. solilokiam/httprediscache

ActiveLibrary

solilokiam/httprediscache
=========================

An HttpCache extension with redis for Symfony 2

77237[2 PRs](https://github.com/solilokiam/HttpRedisCache/pulls)PHP

Since Oct 19Pushed 8y ago2 watchersCompare

[ Source](https://github.com/solilokiam/HttpRedisCache)[ Packagist](https://packagist.org/packages/solilokiam/httprediscache)[ RSS](/packages/solilokiam-httprediscache/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

README
======

[](#readme)

What is HttpRedisCache?
-----------------------

[](#what-is-httprediscache)

Redis Cache is an improvement to Symfony 2 internal http cache. All cached data is stored in Redis instead of filesystem. This can be useful when not much spacedisk is avaliable, or you want to share the cache data across several servers.

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

[](#requirements)

HttpRedisCache is only supported by symfony 2.3 . Any other versions may or may not work. Redis php extension installed.

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

[](#installation)

Add HttpRedisCache to your application's `composer.json` file

```
{
    "require": {
        "solilokiam/httprediscache": "dev-master"
    }
}
```

Install the library and it's dependencies using the following command:

```
$ php composer.phar update solilokiam\httprediscache
```

Activate your symfony [internal http cache](http://symfony.com/doc/current/book/http_cache.html#symfony2-reverse-proxy):

```
// web/app.php
require_once __DIR__.'/../app/bootstrap.php.cache';
require_once __DIR__.'/../app/AppKernel.php';
require_once __DIR__.'/../app/AppCache.php';

use Symfony\Component\HttpFoundation\Request;

$kernel = new AppKernel('prod', false);
$kernel->loadClassCache();
// wrap the default AppKernel with the AppCache one
$kernel = new AppCache($kernel);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
```

Make `AppCache` class extend HttpRedisCache instead on HttpCache like this:

```
// app/AppCache.php
require_once __DIR__.'/AppKernel.php';

class AppCache extends \Solilokiam\HttpRedisCache\HttpRedisCache
{

}
```

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

[](#configuration)

By default this library has the following configuration:

- redis host: localhost
- redis port: 6379
- redis password: ~
- redis database: ~
- redis options: ~

You can change it adding some method implementations in `AppCache`:

```
// app/AppCache.php
require_once __DIR__.'/AppKernel.php';

class AppCache extends \Solilokiam\HttpRedisCache\HttpRedisCache
{
    public function getConnectionParams()
    {
        return array(
            'host' => 'localhost',
            'port' => '6739',
            'password' => 'somepassword',
            'database' => 'somedatabase',
            'options' => array(
                Redis::OPT_SERIALIZER => Redis::SERIALIZER_NONE,
                Redis::OPT_PREFIX => 'myAppName:'
            )
        );
    }
}
```

The only *required* array element is host others are optional.

You can also configure key prefixes adding some implementation methods in `AppCache`:

```
// app/AppCache.php
require_once __DIR__.'/AppKernel.php';

class AppCache extends \Solilokiam\HttpRedisCache\HttpRedisCache
{
    ...

    public function getDigestKeyPrefix()
    {
        return 'hrd';
    }

    public function getLockKey()
    {
        return 'hrl';
    }

    public function getMetadataKeyPrefix()
    {
        return 'hrm';
    }
    ...
}
```

Remember that you can configure other cache settings the sameway you do with default symfony internal http cache.

```
// app/AppCache.php
use Symfony\Bundle\FrameworkBundle\HttpCache\HttpCache;

class AppCache extends HttpCache
{
    protected function getOptions()
    {
        return array(
            'debug'                  => false,
            'default_ttl'            => 0,
            'private_headers'        => array('Authorization', 'Cookie'),
            'allow_reload'           => false,
            'allow_revalidate'       => false,
            'stale_while_revalidate' => 2,
            'stale_if_error'         => 60,
        );
    }
}
```

Build Status
------------

[](#build-status)

[![Build Status](https://camo.githubusercontent.com/ed24086a2fc82726c8e2b0d7a8ec6122d0073d7547a97f1076e3ef93f9e61e49/68747470733a2f2f7472617669732d63692e6f72672f736f6c696c6f6b69616d2f48747470526564697343616368652e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/solilokiam/HttpRedisCache)[![SensioLabsInsight](https://camo.githubusercontent.com/99da86b2175adc2f25a38856a51e9de7c73464fb53dd4f0bbc822e811be4fc04/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f39396435343836312d336337302d346364362d613733642d6631636533316161383836392f6d696e692e706e67)](https://insight.sensiolabs.com/projects/99d54861-3c70-4cd6-a73d-f1ce31aa8869)[![Latest Stable Version](https://camo.githubusercontent.com/c20b89b25c581414e51b07d2ce57b16801c94e8b10ddde1a7ca97980d60ba356/68747470733a2f2f706f7365722e707567782e6f72672f736f6c696c6f6b69616d2f68747470726564697363616368652f762f737461626c652e706e67)](https://packagist.org/packages/solilokiam/httprediscache) [![Total Downloads](https://camo.githubusercontent.com/e1f9c0b23bc5ce41439888d3ee2741e421390d7df831981092b37eaed161d2b4/68747470733a2f2f706f7365722e707567782e6f72672f736f6c696c6f6b69616d2f68747470726564697363616368652f646f776e6c6f6164732e706e67)](https://packagist.org/packages/solilokiam/httprediscache) [![Latest Unstable Version](https://camo.githubusercontent.com/4ab40387e475c76ddc69aef8771355b1d83df0559ea44328d97748240aa7efe5/68747470733a2f2f706f7365722e707567782e6f72672f736f6c696c6f6b69616d2f68747470726564697363616368652f762f756e737461626c652e706e67)](https://packagist.org/packages/solilokiam/httprediscache) [![License](https://camo.githubusercontent.com/07e6a33b79543b20cdb8ebe6b8cdab665759c974959670854f990669bdb77bf5/68747470733a2f2f706f7365722e707567782e6f72672f736f6c696c6f6b69616d2f68747470726564697363616368652f6c6963656e73652e706e67)](https://packagist.org/packages/solilokiam/httprediscache)

Author
------

[](#author)

- Miquel Company Rodriguez (@solilokiam)

TODO
----

[](#todo)

- Improve Tests
- Symfony 2.4 support

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 80% 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/3dae316f71c5e5ec502f548d781a561d0e7080ad4af248f92cdbd3a1ff75295f?d=identicon)[solilokiam](/maintainers/solilokiam)

---

Top Contributors

[![solilokiam](https://avatars.githubusercontent.com/u/650592?v=4)](https://github.com/solilokiam "solilokiam (4 commits)")[![ma-si](https://avatars.githubusercontent.com/u/1869327?v=4)](https://github.com/ma-si "ma-si (1 commits)")

### Embed Badge

![Health badge](/badges/solilokiam-httprediscache/health.svg)

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

PHPackages © 2026

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