Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to store data in cache in symfony2

I have a configuration-table(id,name,value), containing some configuration variables for my symfony application such as email_expiration_duration. I want to write a service to read these configuration varibales from symfony application.

I want cache the data in app/cache folder. That means I will read the data from database only if the data is not in cache. I will clear the cached data whenever the configuration value changes.

How can I do it in symfony2?

like image 283
Mohammed H Avatar asked Aug 08 '12 09:08

Mohammed H


People also ask

How to clear cache in Symfony 5?

Clearing the Cache To clear the cache you can use the bin/console cache:pool:clear [pool] command. That will remove all the entries from your storage and you will have to recalculate all the values.

What is cache in Symfony?

The Cache component provides features covering simple to advanced caching needs. It natively implements PSR-6 and the Cache Contracts for greatest interoperability. It is designed for performance and resiliency, ships with ready to use adapters for the most common caching backends.


1 Answers

If you want to store this information in a file you manually create in the app/cache folder, you may use the following solution: https://stackoverflow.com/a/13410635/1443490

If you don't want/need to care about what folder is used inside the app/cache folder and your project already uses Doctrine, you can follow this solution: https://stackoverflow.com/a/8900283/1443490

like image 200
cheesemacfly Avatar answered Oct 24 '22 10:10

cheesemacfly