开发者

Is it better to cache HTML in a database or on the file system?

开发者 https://www.devze.com 2023-03-14 01:22 出处:网络
I have a few programs that have to fetch HTML or XML and then cache it locally. Imagine that there are 1000-10,000 documents that need to be cached. Data is then extracted from the documents and inser

I have a few programs that have to fetch HTML or XML and then cache it locally. Imagine that there are 1000-10,000 documents that need to be cached. Data is then extracted from the documents and inserted into a PostgreSQL database.

My question is whether it would better to cache these documents in TEXT fields on a PostgreSQL table, or whether I should just cache them on the filesystem.

The documents really don't serve much of a purpose beyond temporary caching and perhaps serving as a debugging tool if something goes wrong with t开发者_StackOverflow社区he data extraction.


If you store things in the filesystem, ideally do so in a RAM disk.

If you do so in the database, ideally do so with a tablespace that lives in a RAM disk. In PG 9.1 (in beta), additionally make sure that your table is unlogged (so as to not need to write in the WAL).

Even more ideally, though, place all of this in Memcache... (Or whichever other applicable memory-based cache solution your platform offers.)


Caching in the database will allow the database engine to keep it in memory, possibly reducing disk access and improving performance.

0

精彩评论

暂无评论...
验证码 换一张
取 消