This Bundle provides integration into Symfony2 with the Doctrine Common Cache layer
Using submodules
$ git submodule add git://github.com/liip/LiipDoctrineCacheBundle.git vendor/bundles/Liip/DoctrineCacheBundle
Using composer
Add the following lines in your deps
file:
"require": {
...
"liip/doctrine-cache-bundle": "dev-master"
}
Now, run composer to download the bundle:
$ composer update
<?php
// app/autoload.php
$loader->registerNamespaces(array(
'Liip' => __DIR__.'/../vendor/bundles',
// your other namespaces
));
<?php
// application/ApplicationKernel.php
public function registerBundles()
{
return array(
// ...
new Liip\DoctrineCacheBundle\LiipDoctrineCacheBundle(),
// ...
);
}
Simply configure any number of cache services:
# app/config.yml
liip_doctrine_cache:
namespaces:
# name of the service (aka liip_doctrine_cache.ns.foo)
foo:
# cache namespace is "ding", this is optional
namespace: ding
# cache type is "apc"
type: apc
# name of the service (aka liip_doctrine_cache.ns.lala) and namespace
lala:
# cache type is "file_system"
type: file_system
# optionally define a directory
directory: /tmp/lala
# name of the service (aka liip_doctrine_cache.ns.bar)
bar:
# cache namespace is "dong"
namespace: dong
# cache type is "memcached"
type: memcached
# name of a service of class Memcached that is fully configured (optional)
id: my_memcached_service
# port to use for memcache(d) (default is 11211)
port: 11211
# host to use for memcache(d) (default is localhost)
host: localhost
Simply use liip_doctrine_cache.ns.[your_name]
in dependency injection config files or using $container->get('liip_doctrine_cache.ns.[your_name]')
in your code.
Simply define a new type by defining a service named liip_doctrine_cache.[type name]
.
Note the service needs to implement Doctrine\Common\Cache\Cache
interface.