Custom Providers

You can also register your own custom cache drivers:

  • YAML
    1# app/config/services.yml services: my_custom_provider_service: class: "MyCustomType" # ... # app/config/config.yml doctrine_cache: custom_providers: my_custom_type: prototype: "my_custom_provider_service" definition_class: "MyCustomTypeDefinition" # optional configuration providers: my_custom_type_provider: my_custom_type: config_foo: "foo" config_bar: "bar"
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
  • XML
    1<!-- app/config/config.xml --> <?xml version="1.0" encoding="UTF-8" ?> <dic:container xmlns="http://doctrine-project.org/schemas/symfony-dic/cache" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:srv="http://symfony.com/schema/dic/services" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://doctrine-project.org/schemas/symfony-dic/cache http://doctrine-project.org/schemas/symfony-dic/cache/doctrine_cache-1.0.xsd"> <srv:container> <srv:services> <srv:service id="my_custom_provider_service" class="MyCustomType"> <!-- ... --> </srv:service> </srv:services> <doctrine-cache> <!-- register your custom cache provider --> <custom-provider type="my_custom_type"> <prototype>my_custom_provider_service</prototype> <definition-class>MyCustomTypeDefinition</definition-class> <!-- optional configuration --> </custom-provider> <provider name="my_custom_type_provider"> <my_custom_type> <config-foo>foo</config-foo> <config-bar>bar</config-bar> </my_custom_type> </provider> </doctrine-cache> </srv:container>
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30

Definition class is a optional configuration that will parse option arguments given to your custom cache driver. See CacheDefinition code.