Skip to content

Configure a custom marshaller in cache framework bundle per cache pool #59366

Open
@mvanduijker

Description

@mvanduijker

Description

I couldn't figure out a way to configure a custom marshaller service in per cache pool configuration in the framework bundle. So I can configure an encrypting or compressing marshaller per cache pool.

It is documented how to overwrite the marshaller service but then that's used for all cache pools.

If it's already possible, may we should improve the documentation how to do this.

Example

# config/packages/cache.yaml

framework:
    cache:
        pools:
            local_cache:
                adapter: apcu
                marshaller: '@app.cache.compressing_marshaller'

            token_cache:
                adapter: cache.adapter.redis
                marshaller: '@app.cache.encrypting_marshaller'

services:
    app.cache.encrypting_marshaller:
        class: Symfony\Component\Cache\Marshaller\SodiumMarshaller
        arguments:
            - ['%env(base64:CACHE_DECRYPTION_KEY)%']
            # use multiple keys in order to rotate them
            #- ['%env(base64:CACHE_DECRYPTION_KEY)%', '%env(base64:OLD_CACHE_DECRYPTION_KEY)%']
            - '@cache.default_marshaller'
      
    app.cache.compressing_marshaller:
        class: Symfony\Component\Cache\Marshaller\DeflateMarshaller
        arguments:
            - '@cache.default_marshaller'

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions