当必须将图片作为blob存储在数据库中时,将图片发送到浏览器的最佳方法是什么? [英] What's the best way to send pictures to a browser when they have to be stored as blobs in a database?

查看:186
本文介绍了当必须将图片作为blob存储在数据库中时,将图片发送到浏览器的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个现有的数据库,其中包含blob字段中的一些图片。对于Web应用程序,我必须显示它们。

I have an existing database containing some pictures in blob fields. For a web application I have to display them.

考虑到服务器上的压力以及维护和编码工作,最好的方法是什么。

What's the best way to do that, considering stress on the server and maintenance and coding efforts.

我可以想到以下内容:


  • 将blob缓存到外部文件并发送文件到浏览器。

  • 每次请求时直接从数据库中读取它们。

一些附加事实:


  • 我无法更改数据库并完全删除blob,只保存数据库中的文件引用(就像在访问日期一样),因为数据库是由另一个实际需要blob的应用程序使用的。

  • 图像变化很少,即如果图像在数据库中,它大部分都会永远保持这种状态。

  • 对图片进行多次读取访问,每个视图将显示10-100张图片。 (取决于用户的设置)

  • 图片相对较小,< 500 KB

  • I cannot change the database and get rid of the blobs alltogether and only save file references in the database (Like in the good ol' Access days), because the database is used by another application which actually requires the blobs.
  • The images change rarely, i.e. if an image is in the database it mostly stays that way forever.
  • There'll be many read accesses to the pictures, 10-100 pictures per view will be displayed. (Depending on the user's settings)
  • The pictures are relativly small, < 500 KB

推荐答案

我建议结合你的两个想法:第一次请求该项从数据库中读取它。但之后确保它们被像Squid这样的东西缓存,这样你就不必在每次请求时都检索它们。

I would suggest a combination of the two ideas of yours: The first time the item is requested read it from the database. But afterwards make sure they are cached by something like Squid so you don't have to retrieve the every time they are requested.

这篇关于当必须将图片作为blob存储在数据库中时,将图片发送到浏览器的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆