且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从文件系统或磁盘路径读取缓存数据

更新时间:2023-11-29 15:00:04

答案取决于您的Ehcache版本。

The answer depends on your version of Ehcache.

与Ehcache 2.6相比,存储模型不再是溢出模型,而是分层模型。
在分层存储模型中,所有数据将始终出现在最低层中。
项目将根据其热度较高层中出现。

As of Ehcache 2.6, the storage model is no longer an overflow one but a tiered one. In the tiered storage model, all data will always be present in the lowest tier. Items will be present in the higher tiers based on their hotness.

可能的开放层源Ehcache是​​:

Possible tiers for open source Ehcache are:


  • JVM堆上的堆上

  • 在磁盘上是最低的

按定义,高层比较低层具有更低的延迟,但容量较低。

By definition high tiers have lower latency but less capacity than lower tiers.

因此,对于配置了 overflowToDisk 的缓存,所有数据将始终位于磁盘层内部。它将密钥存储在内存中,并将数据存储在磁盘上。

So for a cache configured with overflowToDisk, all the data will always be inside the disk tier. It will store the key in memory and the data on disk.

在高速缓存中查找条目时,层级从最高到最低。
在您的示例中,将按以下方式检索数据:

When looking for an entry inside the cache, the tiers are considered from highest to lowest. In your example, the data will be retrieved as follows:


  1. 在内存中搜索

    • 如果找到,将其退回


  • 如果找到,则添加到内存层(热数据)并返回它。这可能会导致从内存中逐出另一个条目


  • 找到后,将其添加到缓存中并返回