缓存/池/缓存池的指南/差异

发布于 2024-07-09 01:48:39 字数 146 浏览 6 评论 0原文

我正在做一些设计(最初是针对 Java)(但将来可能会扩展到.NET?)并且我对术语“缓存”和“池”感到困惑。

据我所知,主要区别在于它们包含什么?

关于何时应该使用哪些指南?

那么,许多文章中提到的“缓存池”是什么?

I'm doing some design (initially for Java) (but may extend to .NET in the future?) and I'm getting confused between the terms "cache" and "pool".

As far as I can see, the main point of difference is what is contained in them?

Any guidelines as to which should be used when?

And what then is a "cache pool" which is referred to in a number of articles?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

掩饰不了的爱 2024-07-16 01:48:39

虽然它们都指的是保留物体,但它们是完全不同的,我不会说它们是可以互换的。

缓存 - 存储经常使用的值,通常是因为查找和/或创建非常重要。 例如,如果频繁使用数据库中的查找表,或者从磁盘上的文件读取值,则将其保留在内存中并定期刷新会更有效。

缓存仅管理缓存中的对象生存期,但不会对缓存中保存的内容强加语义。 缓存也不创建项目,而只是存储对象。

- 描述由池本身管理的一组资源的术语。 例如(数据库)连接池 - 当需要连接时,从池中获取连接,完成后将其返回到池中。

池本身处理池对象的创建和销毁,并管理一次可以创建多少个对象。

缓存池 - 主要似乎描述了存在的(独立?)缓存的数量。 例如,一个 ASP.NET 应用程序的每个应用程序域有 1 个缓存(缓存不在 ASP.NET 应用程序之间共享)。 字面意思是缓存池,尽管这个术语似乎很少使用。

Although they both refer to keeping objects around, they are quite different, and I wouldn't say they're interchangeable.

Cache - store frequently used values, typically because the lookup and/or creation is non-trivial. e.g. if a lookup table from a database is frequently used, or values are read from a file on disk, it's more efficient to keep it in memory and refresh it periodically.

A cache only manages object lifetime in the cache, but does not impose semantics on what is held in the cache. A cache also doesn't create the items, but just stores objects.

Pool - term to describe a group of resources that are managed by the pool itself. e.g. (Database) Connection Pool - When a connection is needed it is obtained from the pool, and when finished with is returned to the pool.

The pool itself handles creation and destruction of the pooled objects, and manages how many objects can be created at any one time.

Cache Pool - mostly seems to describe the number of (independent?) cache's that exist. E.g. an asp.net application has 1 cache per Application Domain (cache isn't shared between asp.net applications). Literally a pool of caches, although this term seems to be used rarely.

蹲在坟头点根烟 2024-07-16 01:48:39

缓存通常用于保存昂贵操作的结果或优化这些结果的检索。

用于描述可供一个或多个应用程序使用的资源集合,但允许控制这些资源的数量。

我没有遇到过“缓存池”这个术语 - 但根据快速回顾,它似乎用于缓存,或缓存的集合由池管理。

Cache is generally for saving the results of expensive operations or to optimize retrieval of those results.

Pool is used to describe a collection of resources that is available for one or more applications to use but allows for control of the number of these resources.

I've not run across the term "cache pool" - but based on a quick review, it appears to used for a pool of caches, or a collection of caches managed by a pool.

吹梦到西洲 2024-07-16 01:48:39

我同意 Ken 的观点,并补充一点——如果任何时候从缓存中删除部分或全部资源,缓存不会影响您的系统——数据都很容易再现/可重新获取,并且再现通常是自动的(你向缓存请求一些东西,如果它不存在于缓存中,缓存就会创建一个,保存它并将其返回给你)。

“池”可以是任何东西,但您不能因为池对象陈旧而删除它们——通常池包含某些资源的唯一的、可能不可复制的实例。

I agree with Ken, and to add a little--a Cache would not effect your system if some or all of the resources were removed from it at any time--the data is all easily reproducable/refetchable, and the reproducing is generally automatic (you ask the cache for something, if it doesn't exist in the cache, the cache makes one, saves it and returns it to you).

A "Pool" can be anything, but you don't just delete pool objects because they are old--usually a pool contains unique, maybe unreproducible instances of some resource.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文