Answer the question
In order to leave comments, you need to log in
How to set FilesystemAdapter to work in the default cache folder in symfony 4.3?
Good day, for caching data in symfony 4 I use the FilesystemAdapter
By default I use it quite simply
But when I save the cache it is saved in the /tmp/symfony-cache/ folder
I don’t like this state of affairs, I want it to be saved there where is the main cache
./var/cache
Of course, I looked at the
FilesystemAdapter constructor$cachePool = new FilesystemAdapter();
public function __construct(string $namespace = '', int $defaultLifetime = 0, string $directory = null, MarshallerInterface $marshaller = null)
Answer the question
In order to leave comments, you need to log in
SF4 uses the file cache by default (see framework.cache ). In this case, you need to use DI in the class constructor or controller method where this cache is needed.
public function __construct(AdapterInterface $cache) { /* ... */ }
# config/packages/framework.yaml
framework:
# ...
cache:
pools:
cache.mycache:
adapter: cache.adapter.filesystem
# other options
$adapter = $container->get('app.cache.mycache');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question