Commons VFS 缓存是如何工作的?

How does the Commons VFS Cache works?

我正在尝试学习如何使用 Apache Commons VFS2。

我已经阅读了我能找到的所有文档,并且我已经对 API 有点熟悉了,但仍有一件事我不太清楚。

Cache机制是如何工作的?特别是:

当我尝试在我的机器上本地使用不同的缓存策略时,我并没有发现任何行为上的差异。它们的行为都相同,并且文件始终与 FS 同步(或者至少它们不同步并不明显)。

CacheStrategy basically controls the re-syncing of meta data inside a FileObject in-between multiple calls. The FileObject 决定何时刷新其世界观。

它会在你每次 resolve 时调用 refresh(),或者它会在每次 FileObject 方法调用之前调用 refresh()(通过 OnCallRefreshFileObject 装饰器)或者永远不会自动。

refresh() 大部分时间将 FileObject 状态设置为分离,因此在下一个操作检查 attach().

时会重新读取它

它主要与属性和子项等元数据有关,我认为没有任何文件系统提供商实际缓存内容。

FilesCache is actually responsible for caching instances of the FileObject inbetween resolveFile() calls. So you if happen to resolve or navigate to the same file, you will also get the same java object instance (unless you use the NullFilesCache or the LRUFilesCache 缓存中的一些条目已过期。