简体   繁体   中英

How to configure BigMemory for disk persistence?

I'm using ehcache to persist data on the disk for JVM restarts. Since the data is very big, I want to try the BigMemory Go product. But in their documentation I did not find any mention of disk configuration (max size, path). With ehcache my configuration look like this:

PersistentCacheManager persistentCacheManager = 
newCacheManagerBuilder()
.with(persistence(new File("path_to_cache_dest"))
.withCache("myType"), newCacheConfigurationBuilder(String.class, String.class, newResourcePoolsBuilder()
.disk(2, MemoryUnit.GB, true))
.build(true);

What is the equivalent in BigMemory Go? What is the object dealing with disk persistence in BigMemory? A code sample would be great.

BigMemory Go is a commercial product based on Ehcache 2.x. It is thus unrelated to Ehcache 3.x as it uses a different code base and different APIs.

So you would need to configure Ehcache 2.x for disk persistence and then run that configuration with the commercial version which would then use the commercial disk store:

new CacheManager(new Configuration()
    .cache(new CacheConfiguration("aCache", 10000)
        .persistence(new PersistenceConfiguration().strategy(PersistenceConfiguration.Strategy.LOCALRESTARTABLE))    
        .maxBytesLocalDisk(2, MemoryUnit.GB)
        .timeToLiveSeconds(1000)
        .timeToLiveSeconds(360))
    .name("testDiskStoreSize")
    .diskStore(new DiskStoreConfiguration().path("java.io.tmpdir/testDiskStoreSize")));

Note that the above would still work in open source if you were to replace Strategy.LOCALRESTARTABLE with Strategy.LOCALTEMPSWAP . You would only loose the crash proof restartability and use a different disk storage model.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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