简体   繁体   中英

cache issues in php (Laravel)

we are making web api's, using Laravel in back end, immediately a day our server has stopped responding then we checked that our cache file has reached beyond the our server's space. i have surprised and wondered, so here i want to know from expert that why happened this with us , is there because we are using heavy video files(conference videos we are using web RTC in front end) ?? or is there any other issues may happened ?? please give your views so that we can track the issues and resolve immediately so that never happened in future. Thanks in advance

From the Laravel documentation:

By default, Laravel is configured to use the file cache driver, which stores the serialized, cached objects in the filesystem. For larger applications, it is recommended that you use a more robust driver such as Memcached or Redis.

If you're using the file driver, it would be best to switch to a more robust driver like Redis, Memcached, Varnish, etc.

As to why your cache file outsized your server's space, there could be multiple reasons:

  1. You may be caching stuff indefinitely using something like Cache::forever and not removing items for cache afterwards with Cache::forget
  2. You may be caching heavy items: eg large database queries, heavy views / responses, heavy file content, etc.
  3. Or there is a slight possibility, that your api's traffic has spiked incredibly and you genuinely need a hardware upgrade :)

I'm not sure if there's a way (for the file driver) to figure out which keys are occupying the most cache space but if you switch over to a redis or memcached cache driver for some time, you can easily list the size of the cache grouped by the cache key and figure out what heavy items your code is actually caching!

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