I have a big database, and I get data from there and stored in an array. I am 开发者_开发问答working in this data, but I don't want to get every time this data from the database, I want to cache it, it's enought for me to get each 5 minutes. How could I cache an array?
Thanks for your help.
There are many ways to cache data. Have a look at memcache as a way to store data in server memory between PHP requests.
http://php.net/manual/en/book.memcache.php
Simply you can install APC cache. It uses internal memory of your server.
After you can set array with apc_store('key_name', serialize($array))
and fetch with apc_fetch('key_name')
Also you can define expiration time for caches.
Its very easy and fast.
精彩评论