@Override public MeterBinder getMeterBinder(HazelcastCache cache, Iterable<Tag> tags) { return new HazelcastCacheMetrics(cache.getNativeCache(), tags); }
private <T> T loadValue(Object key, Callable<T> valueLoader) { T value; try { value = valueLoader.call(); } catch (Exception ex) { throw ValueRetrievalExceptionResolver.resolveException(key, valueLoader, ex); } put(key, value); return value; }
@Override public Cache getCache(String name) { Cache cache = caches.get(name); if (cache == null) { IMap<Object, Object> map = hazelcastInstance.getMap(name); cache = new HazelcastCache(map); long cacheTimeout = calculateCacheReadTimeout(name); ((HazelcastCache) cache).setReadTimeout(cacheTimeout); Cache currentCache = caches.putIfAbsent(name, cache); if (currentCache != null) { cache = currentCache; } } return cache; }
@Override public ValueWrapper get(Object key) { if (key == null) { return null; } Object value = lookup(key); return value != null ? new SimpleValueWrapper(fromStoreValue(value)) : null; }
private void parseOptions(String options) { if (null == options || options.trim().isEmpty()) { return; } for (String option : options.split(",")) { parseOption(option); } }
@Override public void put(Object key, Object value) { if (key != null) { map.set(key, toStoreValue(value)); } }
private long calculateCacheReadTimeout(String name) { Long timeout = getReadTimeoutMap().get(name); return timeout == null ? defaultReadTimeout : timeout; }
@Override public Cache getCache(String name) { Cache cache = caches.get(name); if (cache == null) { IMap<Object, Object> map = hazelcastInstance.getMap(name); cache = new HazelcastCache(map); long cacheTimeout = calculateCacheReadTimeout(name); ((HazelcastCache) cache).setReadTimeout(cacheTimeout); Cache currentCache = caches.putIfAbsent(name, cache); if (currentCache != null) { cache = currentCache; } } return cache; }
@Override public ValueWrapper get(Object key) { if (key == null) { return null; } Object value = lookup(key); return value != null ? new SimpleValueWrapper(fromStoreValue(value)) : null; }
private <T> T loadValue(Object key, Callable<T> valueLoader) { T value; try { value = valueLoader.call(); } catch (Exception ex) { throw ValueRetrievalExceptionResolver.resolveException(key, valueLoader, ex); } put(key, value); return value; }
private void parseOptions(String options) { if (null == options || options.trim().isEmpty()) { return; } for (String option : options.split(",")) { parseOption(option); } }
@Override public void put(Object key, Object value) { if (key != null) { map.set(key, toStoreValue(value)); } }
private long calculateCacheReadTimeout(String name) { Long timeout = getReadTimeoutMap().get(name); return timeout == null ? defaultReadTimeout : timeout; }
@Override public Cache getCache(String name) { Cache cache = caches.get(name); if (cache == null) { IMap<Object, Object> map = hazelcastInstance.getMap(name); cache = new HazelcastCache(map); long cacheTimeout = calculateCacheReadTimeout(name); ((HazelcastCache) cache).setReadTimeout(cacheTimeout); Cache currentCache = caches.putIfAbsent(name, cache); if (currentCache != null) { cache = currentCache; } } return cache; }
@Override public ValueWrapper get(Object key) { if (key == null) { return null; } Object value = lookup(key); return value != null ? new SimpleValueWrapper(fromStoreValue(value)) : null; }
private <T> T loadValue(Object key, Callable<T> valueLoader) { T value; try { value = valueLoader.call(); } catch (Exception ex) { throw ValueRetrievalExceptionResolver.resolveException(key, valueLoader, ex); } put(key, value); return value; }
private void parseOptions(String options) { if (null == options || options.trim().isEmpty()) { return; } for (String option : options.split(",")) { parseOption(option); } }
@Override public void put(Object key, Object value) { if (key != null) { map.set(key, toStoreValue(value)); } }
private long calculateCacheReadTimeout(String name) { Long timeout = getReadTimeoutMap().get(name); return timeout == null ? defaultReadTimeout : timeout; }
@SuppressWarnings("unchecked") public <T> T get(Object key, Class<T> type) { Object value = fromStoreValue(lookup(key)); if (type != null && value != null && !type.isInstance(value)) { throw new IllegalStateException("Cached value is not of required type [" + type.getName() + "]: " + value); } return (T) value; }