简体   繁体   English

JCS Cache关闭,保证磁盘持久性

[英]JCS Cache shutdown,guaranteed persistence to disk

Iam using JCS for caching.Now I am using disk cache to temporarily store all the data.The problem is when I use JCS,the keys are written to disk only if the cache is properly shutdown. 我使用JCS进行缓存。现在我使用磁盘缓存来临时存储所有数据。问题是当我使用JCS时,只有在缓存正确关闭时才将密钥写入磁盘。

I am using the disk usage pattern as UPDATE which tells JCS to immediately write data to the disk without keeping it in memory.But the problem is we are not maitaining the key list of objects in the cache.So I use group cache access and get the keys from the cache and then iterate through the keys to get the results. 我使用磁盘使用模式作为UPDATE,它告诉JCS立即将数据写入磁盘而不将其保留在内存中。但问题是我们没有保留缓存中对象的密钥列表。所以我使用组缓存访问并获取来自缓存的密钥然后遍历密钥以获得结果。

So now I am caught in a situation where I have to shutdown the cache properly ie after all the data is written to disk using Indexed disk cache.But there is a complexity here,the indexed disk cache uses a background thread to write to disk which does not return anything on its status. 所以现在我陷入了这样一种情况:我必须正确关闭缓存,即在使用索引磁盘缓存将所有数据写入磁盘之后。但是这里存在复杂性,索引磁盘缓存使用后台线程写入磁盘没有返回其状态的任何内容。

So now,I am unable to guarantee that indexed disk cache has written data to the disk to my front end implementation.Is there a way to tackle this situation,because now I am just sleeping some random time(say 10 seconds),before the cache is shutdown,which is a very stupid way of doing it actually. 所以现在,我无法保证索引磁盘缓存已经将数据写入磁盘到我的前端实现。有没有办法解决这种情况,因为现在我只是睡了一些随机时间(比如10秒),之前缓存是关闭的,这实际上是一种非常愚蠢的方式。

Edit : I am facing this issue with Memory Cache as well,but a sleep of one second is mostly enough for 500mb of data.But the case of disk cache is little different. 编辑:我也面临着内存缓存的这个问题,但是一秒的睡眠大部分足以容纳500mb的数据。但是磁盘缓存的情况稍有不同。

It could be because your objects are stored in the memory and waiting to write to disk. 可能是因为您的对象存储在内存中并等待写入磁盘。 If you need to write the objects immediately to disk while in execution then you need to make the MaxObjects of your cache configs to 0 . 如果需要在执行时立即将对象写入磁盘,则需要将缓存配置的MaxObjects设置为0

jcs.region.<yourRegion>.cacheattributes.MaxObjects=0 jcs.region.<yourRegion>.cacheattributes.DiskUsagePattern=UPDATE

I know you already aware of UPDATE . 我知道你已经知道UPDATE Adding it for reference again. 添加它再次参考。

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

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