5

I have a Symfony application, and I would like to use Redis as a caching system. The default caching system for Symfony out of the box is filesystem caching.

from the documentation I learned there are two named caches in Symfony; cache.app and cache.system so I set both to Redis with the following cache.yaml:

framework:
    cache:
    # Put the unique name of your app here: the prefix seed
    # is used to compute stable namespaces for cache keys.
    prefix_seed: myteam/myapp

    default_redis_provider: "redis://redis:6379"

    # The app cache caches to the filesystem by default.
    # Other options include:

    # cache.app via Redis
    app: cache.adapter.redis

    # cache.system also
    system: cache.adapter.redis

After doing this, I loaded an example page and monitored the cache folder. I found that files were still being created in the cache folder, even though keys were being created in Redis.

I know that Symfony do not recommend messing with the files that the Kernel creates in the file cache, but even the cache/prod/Containerxxxxx folder was being written to.

What could be caching in the folder that isn't part of app or system? Is there another named cache that I have missed?

1 Answer 1

11

The files at cache/prod/Containerxxxxx are the compiled container files.

These are always written into your file system and never be written into other, secondary cache systems.

Symfony wouldn't know how to access Redis in the first place without getting that information from the container, the container is always cached to the filesystem when compiled and built.

  • cache.system is used for things like annotations, serializer, and validation; but not for the compiled container itself.

  • cache.app is the application cache, that is available for you to use in your app if you typehint CacheInterface or Psr\\Cache\\CacheItemPoolInterface in your services methods.

Summing up, there is no other cache you can configure so Symfony would store the compiled container there. These files are code and are stored on the filesystem.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.