Example #1
0
 @Override
 public int size() {
   try {
     Long longSize = HierarchicalCacheManager.size(level, name);
     return longSize.intValue();
   } catch (Throwable t) {
     throw new CacheException(t);
   }
 }
Example #2
0
 @Override
 public Collection<V> values() {
   try {
     Collection<V> values = HierarchicalCacheManager.values(level, name);
     return values;
   } catch (Throwable t) {
     throw new CacheException(t);
   }
 }
Example #3
0
 @Override
 public void clear() throws CacheException {
   logger.debug("从redis中删除所有元素");
   try {
     HierarchicalCacheManager.clear(level, name);
   } catch (Throwable t) {
     throw new CacheException(t);
   }
 }
Example #4
0
 @Override
 public V put(K key, V value) throws CacheException {
   logger.debug("根据key从存储 key [" + key + "]");
   try {
     HierarchicalCacheManager.set(level, name, key, value);
     return value;
   } catch (Throwable t) {
     throw new CacheException(t);
   }
 }
Example #5
0
 @SuppressWarnings("unchecked")
 @Override
 public Set<K> keys() {
   try {
     Set<K> keys = new HashSet<K>();
     keys.addAll(HierarchicalCacheManager.keys(level, name));
     return keys;
   } catch (Throwable t) {
     throw new CacheException(t);
   }
 }
Example #6
0
 @Override
 public V remove(K key) throws CacheException {
   logger.debug("从redis中删除 key [" + key + "]");
   try {
     V previous = get(key);
     HierarchicalCacheManager.evict(level, name, key);
     return previous;
   } catch (Throwable t) {
     throw new CacheException(t);
   }
 }
Example #7
0
 @Override
 public V get(K key) throws CacheException {
   logger.debug("根据key从Redis中获取对象 key [" + key + "]");
   try {
     if (key == null) {
       return null;
     } else {
       V value = (V) HierarchicalCacheManager.get(level, name, key);
       return value;
     }
   } catch (Throwable t) {
     throw new CacheException(t);
   }
 }