Ehcache

What is the better option for a multi-level, in-process cache?

拟墨画扇 提交于 2019-12-08 08:01:28
问题 In my spring boot application, I need to implement an in-process multi-level cache Here is an example of the data, which needs to be cached: customer name (key, string) --data entity name (key, string) --config-1 (value, JSONObject) --config-2 (value, JSONObject) I'm planning on having a few hundreds customer entries, each having up to a hundred "config" JSONObjects I'm currently looking at ehcache: Cache cache = manager.getCache("sampleCache1"); Element element = new Element("key1", "value1"

Can same Ehcache object of same CacheManager be used by multiple threads?

十年热恋 提交于 2019-12-08 07:56:09
问题 I have created a Cache object which stores a String as the key and a serialized object as the value. Cache(String--->Object) I am trying to run three Akka threads which retrieve and write into the same Ehcache object in a synchronized way. Thread 1- synchronized (LockForEhcache){ serializedObj = cachename.get("key"); //--- this returns an Object } //modify the serializedObj here.... //Again store the modify Object in the Cache synchronized (LockForEhcache){ cachename.clear(); cachename.put(

using ehcache blocking decorator with hibernate

夙愿已清 提交于 2019-12-08 05:57:55
问题 I'm using ehcache with hibernate and I'd like to use the blocking or SelfPopulating cache to avoid the issues presented in http://ehcache.org/documentation/constructs-0_5.html#mozTocId722946 An expensive operation is required, say rendering a large web page, which takes 30 seconds. The page is not considered stale until it is 5 minutes old. The page is hit very heavily and will be hit an average of 20 times per minute each 5 minutes. Do I have to do this programmatically as http://ehcache.org

EhCache and Database Refresh

ⅰ亾dé卋堺 提交于 2019-12-08 02:45:33
问题 I am using Spring and ehcache. using a query I populate the data into the Cache, this process has to happen every 10 mins. Is there a configuration to set this?? Thanks in Advance 回答1: Typically, ehCache would be used to give a ttl to invalidate your cache automatically. From what I can gather from your question, you are asking to automatically refresh the cache every ten minutes. For that, I would run a scheduled service that evicts and reloads. For example: @Cachable("Foo") public Foo

using ehcache blocking decorator with hibernate

三世轮回 提交于 2019-12-08 02:17:29
I'm using ehcache with hibernate and I'd like to use the blocking or SelfPopulating cache to avoid the issues presented in http://ehcache.org/documentation/constructs-0_5.html#mozTocId722946 An expensive operation is required, say rendering a large web page, which takes 30 seconds. The page is not considered stale until it is 5 minutes old. The page is hit very heavily and will be hit an average of 20 times per minute each 5 minutes. Do I have to do this programmatically as http://ehcache.org/documentation/cache_decorators.html suggests or is there a declarative (in xml) way to do so? thanks a

EHCache error on looking up by cache key

廉价感情. 提交于 2019-12-07 20:02:02
问题 I am using EHCache 1.5.0 on a webapp running on a WebLogic 9.1 instance. Once in a while I run into the following error while getting an element from cache or while checking if an item exists in cache. Has anyone else seen this issue? Any suggestions on how to fix this would be great. Code that causes this issue: getMyCache().isKeyInCache(cacheKey) ehcache configuration: maxElementsInMemory="10000" eternal="false" timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true"

Spring @Cacheable not caching

我的未来我决定 提交于 2019-12-07 18:06:52
问题 Using Spring 3.2 with EhCache 2.9. I've annotated a zero-parameter method as follows: @Cacheable(value="myList", key="#result.method.name") protected List<MyObject> getMyList() { //db query //return list of results } EhCache config: <cache name="myList" statistics="true" maxEntriesLocalHeap="1" timeToLiveSeconds="3600"> <persistence strategy="none" /> </cache> I'd like the database results to be cached. Since this method has no parameters, I've chosen the method name to be the cache key. When

How to change a EhCache members expiry time programmatically

倾然丶 夕夏残阳落幕 提交于 2019-12-07 12:51:39
问题 I would like to change the expiry or set the expiry time of a member of an EhCache via Java code. I know when the object should expire, but I'm unsure how to achieve this. I know I can set it for the whole cache, e.g. Cache cache = manager.getCache("sampleCache"); CacheConfiguration config = cache.getCacheConfiguration(); config.setTimeToIdleSeconds(60); config.setTimeToLiveSeconds(120); config.setMaxEntriesLocalHeap(10000); config.setMaxEntriesLocalDisk(1000000); Can someone suggest how I do

How Can I Get Ehcache To Keep Heap Size Bytes Statistics For Unbounded Caches?

丶灬走出姿态 提交于 2019-12-07 07:38:17
问题 I'm using Ehcache (version 2.7.1) and would like to periodically retrieve stats such as number of elements in the cache and the size of the cache in bytes. The problem that I'm running into though is that using net.sf.ehcache.statistics.StatisticsGateway.getLocalHeapSizeInBytes() (StatisticsGateway retrieved by calling net.sf.ehcache.Ehcache.getStatistics() ) takes a very long time with 15000 elements with a total size of about 536MB. In one example on my local machine, it took over 21

Play framework 2.4: NoClassDefFoundError: play/api/cache/CachePlugin

♀尐吖头ヾ 提交于 2019-12-07 06:09:33
问题 In trying to update from Play 2.2 to Play 2.4, I've hit this stumbling block. I've got the memcached2 plugin also added but disabled. my conf file: # Cache configuration # ~~~~~ # To avoid conflict with play2-memcached's Memcached-based cache module play.modules.disabled+="com.github.mumoshu.play2.memcached.MemcachedModule" play.modules.enabled+="play.api.cache.EhCacheModule" # Well-known configuration provided by Play play.modules.cache.defaultCache=default play.modules.cache.bindCaches=["db