为什么Laravel Cache外观如此之慢?

所以我在使用Laravel的预先加载时切换到先检查缓存,然后再点击db。 我已经达到了这样的程度:每个请求只对数据库进行8次查询,而之前使用的是100多个查询。 </ p>

但是,响应时间比以前慢</ em>。 根据这个stackoverflow问题,使用Redis的Laravel缓存非常慢,它 似乎使用缓存外观要比直接调用redis / memcached慢很多。</ p>

为什么缓存外观比直接调用缓存要慢? 我应该切换到直接使用redis / memcached吗? 如果可能的话,在仍然使用缓存外观的同时,我还能做些什么来提高应用程序的性能? </ p>

尽可能地利用缓存并最大限度地减少对数据库的查询次数是我正在开展的这个项目的要求。 </ p>

另外需要注意的是,我正在使用memcached和redis作为缓存驱动程序,因为有些东西存储在memcached中,这些东西在我正在编写的服务之间共享 和旧的服务,有些项目是我正在编写的服务,我可以使用Redis代替。</ p>
</ div>

展开原文

原文

So I switched over from using Laravel's eager loading to checking the cache first before hitting the db. I've got it to the point where it's only doing 8 queries to the database per request vs the 100+ queries it was using before.

However, the response time is now slower than it was before. Per this stackoverflow question, Laravel Caching with Redis is very slow, it seems that using the cache facade is a lot slower than calling redis/memcached directly.

Why is the cache facade slower than calling the cache directly? Should I switch over to using redis/memcached directly? What can I do to improve the performance of my application while still using the cache facade, if possible?

Leveraging caching as much as possible and minimizing the number of queries to the DB is a requirement for this project I'm working on.

Another thing to note is that I'm using both memcached and redis for the cache drivers, as there are some things that are stored in memcached that are shared between the services I'm writing and the old services, and there are items that are exclusive to the services I'm writing which I can use Redis for instead.

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐