public boolean isExpired(final String region, final Object key) { return exists(region, key); }
@Override public long getSizeInMemory() { try { return redis.dbSize(); } catch (Throwable ignored) { log.warn("Fail to get count of cache items. region=" + name, ignored); return -1; } }
@SuppressWarnings("unchecked") @Override public Map toMap() { return redis.getAll(regionName); }
public void put(Object key, Object value) { try { redis.set(getName(), key, value, getExpiryInSeconds()); } catch (Exception e) { log.warn("Fail to put cache item... key=" + key, e); } }
public void remove(Object key) throws CacheException { try { redis.del(getName(), key); } catch (Exception ignored) { log.warn("Fail to remove cache item... key=" + key, ignored); } }
@Override public void evictAll() throws CacheException { try { redis.deleteRegion(getName()); } catch (Exception ignored) { log.warn("Fail to evict all.", ignored); } } }
@Override public Object get(SessionImplementor session, Object key) throws CacheException { try { return redis.get(getName(), key); } catch (Exception ignored) { return null; } }
@Override public long getElementCountInMemory() { try { return redis.keySizeInRegion(name); } catch (Throwable ignored) { log.warn("Fail to get count of cache items. region=" + name, ignored); return -1; } }
@Override public synchronized void stop() { log.debug("Stopping SingletonRedisRegionFactory..."); if (ReferenceCount.decrementAndGet() == 0) { try { redis.shutdown(); redis = null; cacheTimestamper = null; log.info("stopped SingletonRedisRegionFactory"); } catch (Exception ignored) { log.warn("Error occurred in stopping hibernate-redis client.", ignored); } } }
@Override public void stop() { if (redis == null || redis.isShutdown()) return; log.debug("Stopping RedisRegionFactory..."); try { redis.shutdown(); redis = null; cacheTimestamper = null; log.info("RedisRegionFactory is stopped."); } catch (Exception e) { log.error("Fail to stop RedisRegionFactory.", e); throw new CacheException(e); } }
public static RedisClient createRedisClient(@NonNull final Config config) { try { if (config.getCodec() == null) { config.setCodec(new SnappyCodec()); } log.debug("Set Redisson Codec = {}", config.getCodec().getClass().getName()); RedissonClient redisson = Redisson.create(config); return new RedisClient(redisson); } catch (Exception e) { log.error("Fail to create RedisClient.", e); throw new RuntimeException(e); } }
@Override public void put(SharedSessionContractImplementor session, Object key, Object value) throws CacheException { try { redis.set(getName(), key, value, getExpiryInSeconds()); } catch (Exception ignored) { log.warn("Fail to put. key=" + key, ignored); } }
public void remove(Object key) throws CacheException { try { redis.del(getName(), key); } catch (Exception e) { log.warn("Fail to remove cache item... key=" + key, e); } }
@Override public void evictAll() throws CacheException { try { redis.deleteRegion(getName()); } catch (Exception ignored) { log.warn("Fail to evict all.", ignored); } } }
public Object get(Object key) { try { return redis.get(getName(), key); } catch (Exception ignored) { log.warn("Fail to get cache item... key=" + key, ignored); return null; } }
@Override public long getElementCountInMemory() { try { return redis.keySizeInRegion(name); } catch (Throwable ignored) { log.warn("Fail to get count of cache items. region=" + name, ignored); return -1; } }
@Override public synchronized void stop() { log.debug("Stopping SingletonRedisRegionFactory..."); if (ReferenceCount.decrementAndGet() == 0) { try { redis.shutdown(); redis = null; cacheTimestamper = null; log.info("stopped SingletonRedisRegionFactory"); } catch (Exception ignored) { log.warn("Error occurred in stopping hibernate-redis client.", ignored); } } }
@Override public void stop() { if (redis == null || redis.isShutdown()) return; log.debug("Stopping RedisRegionFactory..."); try { redis.shutdown(); redis = null; cacheTimestamper = null; log.info("RedisRegionFactory is stopped."); } catch (Exception e) { log.error("Fail to stop RedisRegionFactory.", e); throw new CacheException(e); } }
public static RedisClient createRedisClient(@NonNull final Config config) { try { if (config.getCodec() == null) { config.setCodec(new SnappyCodec()); } log.debug("Set Redisson Codec = {}", config.getCodec().getClass().getName()); RedissonClient redisson = Redisson.create(config); return new RedisClient(redisson); } catch (Exception e) { log.error("Fail to create RedisClient.", e); throw new RuntimeException(e); } }
@Override public void put(SharedSessionContractImplementor session, Object key, Object value) throws CacheException { try { redis.set(getName(), key, value, getExpiryInSeconds()); } catch (Exception ignored) { log.warn("Fail to put. key=" + key, ignored); } }