问题描述
我们想使用Ehcache缓存永远不应该存储到磁盘的敏感数据(数据只能驻留在主内存中).将其完全存储在磁盘上是一种非法的数据,因此需要谨慎对待.
We want to cache, using Ehcache, sensitive data that should never be stored to disk (data can only reside in main memory). It is the kind of data that is illegal for it to be stored on disk at all and therefore needs to be treated with a certain caution.
我们已经将Ehcache(带或不带兵马俑)用于一般的缓存目的.
We are already using Ehcache (both with and without terracotta) for common caching purposes.
我知道Ehcache提供了同时缓存到主内存和磁盘的选项,此外,它允许在使用主内存时溢出到磁盘.
I know that Ehcache provides the option to cache on both to main memory and to disk, and additionally it allows to overflowtodisk when using main memory.
我是Ehcache的新手,并且想知道如何配置Ehcache,以确保该特定缓存永远不会碰到磁盘.(我们目前主要使用默认配置)此外,一旦运行了实现(确认没有数据没有存储在磁盘上),便可以使用一种方法来确认将数据存储在何处.
I am new to Ehcache, and would like to know of how to configure Ehcache so as to guarantee that this particular cache never touches the disk. (we are currently mostly using default configuration) Additionally it would be nice to have a way to confirm where data is being stored once we have the implementation running (to confirm that no data is not stored the disk).
推荐答案
在缓存级别:
旧的 overflowToDisk
配置设置默认为 false
.现代的 persistence
元素(如果不存在)默认为 none
.在这两种情况下,配置的缓存都不会具有磁盘层,因此不会将任何条目写入磁盘.
The legacy overflowToDisk
configuration setting is false
by default. The modern persistence
element, if absent, defaults to none
.In both these cases, the cache configured will not have a disk tier and so will not write any entries to disk.
如果同一缓存管理器托管磁盘支持的缓存,它将在配置的文件夹(或 java.io.tmpdir
)中创建文件,该文件夹的路径中将包含缓存名称.由于此名称被编码为在路径中使用,因此可能不容易匹配,但是您可以评估没有磁盘后端的缓存在此结构中没有创建任何文件.
If the same cache manager hosts disk backed caches, it will be creating files in the configured folder - or java.io.tmpdir
- which will have the cache name in their path. As this name is encoded to be used in path, it may not be easy to match, but you will be able to assess that your cache without a disk backend does not have any files created in this structure.
这篇关于ehcache避免将敏感数据存储到磁盘吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!