简体   繁体   中英

Laravel 4: Caching JSON Response

I'm totally new to Laravel, and i need to cache a JSON response every 60 min. Saw that Laravel offers lots of caching modules: File, Redis, Memcached, APC.. Which one would suite best for my need? I've red that Memcached and APC are the fastest.

And another thing, when i define caching

Cache::put('key', 'value', $minutes);

should be defined inside Controller or Model?

Well, there's a big difference in caching to a file system or memcached. Memcached has many advantages but keep in mind that the data is stored in the memory, while files are stored on the hard drive, which is much cheaper.

I would say if you're building a smaller site, with not so much traffic, file caching is the better way to go. You want feel the difference that much on sites like that, so no need to over-optimize because of a few milliseconds.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM