@Override public MeterBinder getMeterBinder(HazelcastCache cache, Iterable<Tag> tags) { return new HazelcastCacheMetrics(cache.getNativeCache(), tags); }
@SuppressWarnings("unchecked") public <T> T get(Object key, Callable<T> valueLoader) { Object value = lookup(key); if (value != null) { return (T) fromStoreValue(value); } else { this.map.lock(key); try { value = lookup(key); if (value != null) { return (T) fromStoreValue(value); } else { return loadValue(key, valueLoader); } } finally { this.map.unlock(key); } } }
@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; }
public ValueWrapper putIfAbsent(Object key, Object value) { Object result = map.putIfAbsent(key, toStoreValue(value)); return result != null ? new SimpleValueWrapper(fromStoreValue(result)) : null; }
@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 void put(Object key, Object value) { if (key != null) { map.set(key, toStoreValue(value)); } }
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; }
@SuppressWarnings("unchecked") public <T> T get(Object key, Callable<T> valueLoader) { Object value = lookup(key); if (value != null) { return (T) fromStoreValue(value); } else { this.map.lock(key); try { value = lookup(key); if (value != null) { return (T) fromStoreValue(value); } else { return loadValue(key, valueLoader); } } finally { this.map.unlock(key); } } }
@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; }
public ValueWrapper putIfAbsent(Object key, Object value) { Object result = map.putIfAbsent(key, toStoreValue(value)); return result != null ? new SimpleValueWrapper(fromStoreValue(result)) : null; }
@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 void put(Object key, Object value) { if (key != null) { map.set(key, toStoreValue(value)); } }
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; }
@SuppressWarnings("unchecked") public <T> T get(Object key, Callable<T> valueLoader) { Object value = lookup(key); if (value != null) { return (T) fromStoreValue(value); } else { this.map.lock(key); try { value = lookup(key); if (value != null) { return (T) fromStoreValue(value); } else { return loadValue(key, valueLoader); } } finally { this.map.unlock(key); } } }
@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; }
public ValueWrapper putIfAbsent(Object key, Object value) { Object result = map.putIfAbsent(key, toStoreValue(value)); return result != null ? new SimpleValueWrapper(fromStoreValue(result)) : null; }
@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 void put(Object key, Object value) { if (key != null) { map.set(key, toStoreValue(value)); } }
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 ValueWrapper get(Object key) { if (key == null) { return null; } Object value = lookup(key); return value != null ? new SimpleValueWrapper(fromStoreValue(value)) : null; }