开发者

Php array cache

开发者 https://www.devze.com 2023-02-16 11:39 出处:网络
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,

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消