简体   繁体   English

JCS磁盘缓存问题

[英]JCS Disk Cache Issue

我正在使用JCS进行缓存,我遇到的问题是数据没有写入磁盘,即没有错误发生,但是当我查看数据文件时,它们都是0k大小。任何人都知道是什么导致的这个错误,我使用的是JCS网站提供的属性文件。

One of the cacheattributes is DiskUsagePatternName. 其中一个cacheattributes是DiskUsagePatternName。 The value can either be SWAP or UPDATE. 值可以是SWAP或UPDATE。 SWAP is the default. SWAP是默认值。 UPDATE writes the cache data to disk right away. UPDATE立即将缓存数据写入磁盘。

In your cache.ccf add a line for 在你的cache.ccf中添加一行

jcs.region.[yourregionid].cacheattributes.DiskUsagePatternName=UPDATE

That way it will write to disk without needing to shutdown the cache and you can still get the benefits of the memory cache. 这样它将写入磁盘而无需关闭缓存,您仍然可以获得内存缓存的好处。

The disk cache only writes the data when the cache object is disposed. 磁盘高速缓存仅在释放高速缓存对象时写入数据。 In a web application I had to explicily call dispose() in the destroy() method of my servlet. 在Web应用程序中,我不得不在我的servlet的destroy()方法中明确地调用dispose()。 If you don't call dispose() and don't have have the disk usage pattern set to UPDATE it won't write to disk. 如果不调用dispose()并且没有将磁盘使用模式设置为UPDATE,则它将不会写入磁盘。

Do you know its an error? 你知道它的错误吗? Perhaps it only writes to disk when the cache is over some limit. 也许只有当缓存超过某个限制时才会写入磁盘。 ie it only writes when it has to. 即它只在必要时写入。

Using Madhu's solution: When jcs.default.cacheattributes.MaxObjects=0 the file size will always be 0. Remove this and you can see data in the files. 使用Madhu的解决方案:当jcs.default.cacheattributes.MaxObjects=0 ,文件大小将始终为0.删除此文件,您可以看到文件中的数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM