缓存数据库查询结果
在我的新网站上,我显示大部分图像而不是文本。我显示了最近撰写的、最近查看的、最常查看的帖子等的图像。我发现在 40% 的情况下帖子是相同的。所以我不需要点击数据库来提取图像。它可以节省 Db 和 Db 的点击次数。处理时间。
我最初想到缓存帖子 ID。因此,在查询数据库或处理内容以提取图像之前,我可以在缓存中搜索帖子 ID。如果在缓存中找到帖子 ID,那么我可以直接显示磁盘中的图像。
我发现有很多插件可以缓存数据库查询及其结果。请告诉我它是否可以满足我的要求,或者我应该编写自己的逻辑。
On my new site i am displaying most of the images instead of text. I show images for recently written, recently viewed, mostly viewed posts etc. I found that in 40% of cases posts are same. so i need not to hit the DB to extract the image. It can save number of hits to Db & processing time.
I initially thought to cache post IDs. So before querying to DB or processing contents to extract image, i can search for post id into cache. If post id found in cache then i can directly show image from disk.
I found that there are many of the plugins who cache DB queries and their result. Please tell me whether it can fulfill my requirement or i should write my own logic.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否将图像存储在数据库中?那么你就错了,你应该只存储图像的路径。
与您的答案更相关,您可能需要查看 http ://dev.mysql.com/doc/refman/5.1/en/query-cache.html
另外,您是否遇到过由于数据库查询而导致速度显着下降的情况?仅从您的帖子来看,我想说前端有很多优化可以加快您的网站速度。我在 http://blog.hazardousgaming.info/129 写了一篇非常全面的文章/drastically-improve-page-speed/
注意:我已经几个月没有使用博客并转移到新域了。这不是垃圾邮件帖子,只是这里有太多文字。
Are you storing images in the database? Then you're doing it wrong, you should only store the path to the image.
More related to your answer, you'll probably want to look into http://dev.mysql.com/doc/refman/5.1/en/query-cache.html
Also, do you experience significant slowdowns due to DB queries? Judging by your post only, I'd say there are a lot of optimisations on the frontend that can speed up your website. I wrote a very comprehensive article at http://blog.hazardousgaming.info/129/drastically-improve-page-speed/
Note: I'm not using the blog for a few months now and moving to a new domain. This is not a spam post, just to much text to fit in here.