hautelook/solarium-cache

This package is abandoned and no longer maintained. No replacement package was suggested.

dev-master / 0.1.x-dev 2015-02-17 23:57 UTC

This package is not auto-updated.

Last update: 2020-01-24 15:11:36 UTC


README

Solarium Plugin to cache queries using Doctrine Cache.

Installation

{
    "require": {
        "hautelook/solarium-cache": "0.1@dev"
    }
}

Usage

$client = ...;
$cache = new RedisCache(); // or whichever

$plugin = new CachePlugin();
$plugin->setCache($cache);
$client->registerPlugin('cache', $plugin);

$query = $client->createSelect(array(
    'cache_lifetime' => 60,
));
$result = $client->execute($query);

Usage with the NelmioSolariumBundle

public function registerBundles()
{
    $bundles = array(
        // ...
        new Hautelook\Solarium\Cache\Bundle\HautelookSolariumCacheBundle(),
    );

    // ...

    return $bundles;
}

Configure the bundle which solarium client should have the cache plugin configured, along with the doctrine cache service id.

# app/config/config.yml
liip_doctrine_cache:
    namespaces:
        search:
            namespace: search
            type: memcache
            host: ...
            port: ...

hautelook_solarium_cache:
    clients:
        default: liip_doctrine_cache.ns.search

In this example we use the LiipDoctrineCacheBundle to create a doctrine cache service.