Created
November 16, 2022 10:12
-
-
Save oberhamsi/705e49ead3b0df4bfd17a68de16395cf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('ringo/engine').loadJars(module.resolve("./jars/")); | |
const {CacheManagerBuilder, CacheConfigurationBuilder, | |
ResourcePoolsBuilder} = Packages.org.ehcache.config.builders; | |
const {CacheLoaderWriter} = Packages.org.ehcache.spi.loaderwriter; | |
const main = () => { | |
const loaderReader = new CacheLoaderWriter({ | |
load(key) { | |
console.log('cache loader requested to read key', key); | |
return 'result from loader'; | |
}, | |
loadAll(keys) { | |
// wont happen | |
console.log(keys); | |
} | |
}); | |
const cacheManager = CacheManagerBuilder.newCacheManagerBuilder().build(true); | |
const readThroughCache = cacheManager.createCache("readThroughCache", | |
CacheConfigurationBuilder.newCacheConfigurationBuilder(java.lang.String, java.lang.String, ResourcePoolsBuilder.heap(10)) | |
.withLoaderWriter(loaderReader) | |
.build()); | |
console.log('first cache.get') | |
readThroughCache.get('/test/url'); | |
console.log('second cache.get') | |
readThroughCache.get('/test/url'); | |
}; | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment