Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to correctly invalidate cache on production for Symfony2 application?

I changed the configuration of the application and deployed the new code to production server. Since the application does not parse the configuration files and use precompiled classes I needed to update the cache files.

There is app/console cache:warmup and app/console cache:clear commands. But the cache wasn't updated after invoking these commands, so I had to delete the app/cache folder manually.

Manual deletion is very dangerous operation because it's not atomic so I can remove part of cache during request and this may lead to fatal error.

How should I reload cache?

like image 943
lisachenko Avatar asked Aug 09 '11 09:08

lisachenko


People also ask

What is invalidation in Symfony cache?

The most basic kind of invalidation is direct items deletion. But when the state of a primary resource has spread across several cached items, keeping them in sync can be difficult. The Symfony Cache component provides two mechanisms to help solve this problem: Expiration based invalidation for time-related dependencies.

What are cache tags in Symfony?

Later, when the item is retrieved, Symfony stores the item automatically in all the missing pools. In applications with many cache keys it could be useful to organize the data stored to be able to invalidate the cache more efficiently. One way to achieve that is to use cache tags.

When should I clear the cache in Symfony?

During application development, you have to clear the cache in various situations: When you create a new class: Adding a class to an autoloading directory (one of the project’s lib/ folders) is not enough to have symfony find it automatically.

How do I use a chain of adapters in Symfony?

To get the best of both worlds you may use a chain of adapters. A cache chain combines several cache pools into a single one. When storing an item in a cache chain, Symfony stores it in all pools sequentially. When retrieving an item, Symfony tries to get it from the first pool.


1 Answers

You missed env parameter: app/console cache:clear --env=prod --no-debug

like image 145
Entea Avatar answered Nov 10 '22 04:11

Entea