php - Reduce symfony2 database requests -


i'm developing site symfony2.4 stores "semi-static" info in database (such addresses, telephones, social media url's, etc...) allow client modify data through backend.

the site works fine think should way reduce accesses database retrieving data every request (because printed in pages).

is there way cache data? practice store in user session first time enters site?

thanks.

you should use apc instance. assuming have php-apc extension installed , enabled (you can check in phpinfo) need do:

in config_prod.yml (you don't want results cached in dev environment)

doctrine:     orm:         metadata_cache_driver: apc         result_cache_driver: apc         query_cache_driver: apc 

and in query:

$querybuilder     (...)     ->usequerycache(true)     ->useresultcache(true)     (...) 

first time make query fetch data database. next time fetch data cache. can set lifetime of cache: example

edit: above link symfony 1.x documentation, usage of usequerycache , useresultcache same in symfony 1.x , symfony2.x.

for bigger doc on symfony2 doctrine configuration check this link @francesco casula mentioned


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -