2

I have one table configuration_variables(name,value). It contains configuration variables for my symfony-application such as reset-password-link-expiration-time. Since these configuration variables change rarely, I want to cache it in a temporary folder (app/cache is the right place?).

How can I do it in symfony2?

I tried How to cache in Symfony 2?. But I think it is not suitable to my reqiuirement.

2 Answers 2

3

You could create a cache warmer http://blog.servergrove.com/2012/04/18/how-to-create-a-cache-warmer-in-symfony2/ to cache the configuration in a file. You could use http://php.net/manual/fr/function.var-export.php to export the data to the file, or serialize.

Then, create a service that uses the data from the file.

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

Comments

-2

For such small things you should think about using Redis for your needs. Saving such data in files is bad habit, and Redis offers you great speed for working with data storage.

Redis is an open source, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets.

You can also use SncRedisBundle in pair with it.

4 Comments

Did you just seriously recommend a separate database for caching project configuration parameters?
@Inori your downvote is not objective - I recommended implementation of data, which should be rarely changed but often accessed. Storing this data as cache is bad idea. :\
so you're storing Symfony2 configuration like parameters.ini in Redis?
I don't think storing data in file is bad practice. Most of the application level caching mechanisms are using files for storing data. I don't want to use database for the sake of speed.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.