Usage
=====
First, configure your cache providers under the ``doctrine_cache`` configuration
option. Example:
.. configuration-block::
.. code-block:: yaml
# app/config/config.yml
doctrine_cache:
providers:
my_apc_metadata_cache:
type: apc
namespace: metadata_cache_ns
my_apc_query_cache:
namespace: query_cache_ns
apc: ~
.. code-block:: xml
apc
metadata_cache_ns
Then, use the newly created ``doctrine_cache.providers.{provider_name}`` container
services anywhere in your application::
$metadataCache = $this->container->get('doctrine_cache.providers.my_apc_metadata_cache');
$queryCache = $this->container->get('doctrine_cache.providers.my_apc_query_cache');
Service Aliases
---------------
In order to make your code more concise, you can define aliases for these services
thanks to the ``aliases`` configuration option. Example:
.. configuration-block::
.. code-block:: yaml
# app/config/config.yml
doctrine_cache:
aliases:
apc_cache: my_apc_cache
providers:
my_apc_cache:
type: apc
namespace: my_apc_cache_ns
aliases:
- apc_cache
.. code-block:: xml
my_apc_cache
apc
my_apc_cache_ns
apc_cache
Now you can use the short ``apc_cache`` alias to get the provider called
``my_apc_cache``, instead of using ``doctrine_cache.providers.my_apc_cache``::
$apcCache = $this->container->get('apc_cache');