Follow me on twitter…


First of all, lets configure your Rediska instances (eg. app, otherstuff) in app.yml:

all: rediska: app: servers: server_01: host: persistent: true otherstuff: servers: server_01: host: persistent: true server_02: host: port: 6380 persistent: true

All configuration parameters that Rediska offers when setting up a Rediska instance are available here.

Now we can use these instances to configure a great number of things!

In the above example, we are going to use the app instance as the storage for Symfony internal caching, and otherstuff for caching other critical data.

Symfony Caches

Symfony provides the ability to cache critical parts of your application - session storage, routing, and the view cache.

To configure sfRediskaPlugin for session storage:

storage: class: sfCacheSessionStorage param: cache: class: sfRediskaCache param: lifetime: 86400 prefix: session:%SF_APP%:%SF_ENVIRONMENT% instance: app

For routing:

routing: class: sfPatternRouting param: generate_shortest_url: true extra_parameters_as_query_string: true cache: class: sfRediskaCache param: lifetime: 86400 prefix: routing:%SF_APP%:%SF_ENVIRONMENT% instance: app

For view cache:

view_cache: class: sfRediskaCache param: instance: app prefix: view:%SF_APP%:%SF_ENVIRONMENT%

Doctrine Driver

To setup the Rediska Doctrine driver, first you must edit your application configuration file, eg. frontendConfiguration.class.php


public function configureDoctrine(Doctrine_Manager $manager)
    $cacheDriver = new Doctrine_Cache_Redis(array('instance' => 'otherstuff', 'prefix' => 'dql:'));
    $manager->setAttribute(Doctrine_Core::ATTR_RESULT_CACHE, $cacheDriver);


NOTE: ProjectConfiguration.class.php cannot be used as sfRediskaPlugin depends on configuration variables set at application level.


Fork me on GitHub