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?
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With