当前位置: 首页>>代码示例>>Java>>正文


Java CacheException类代码示例

本文整理汇总了Java中org.apache.shiro.cache.CacheException的典型用法代码示例。如果您正苦于以下问题:Java CacheException类的具体用法?Java CacheException怎么用?Java CacheException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CacheException类属于org.apache.shiro.cache包,在下文中一共展示了CacheException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: clear

import org.apache.shiro.cache.CacheException; //导入依赖的package包/类
@Override
public void clear() throws CacheException {
	Jedis jedis = null;
	try
	{
		jedis = redisManager.getJedis();
    	jedis.select(DB_INDEX);
    	jedis.flushDB();
	}finally
	{
		if(null != jedis)
		{
			jedis.close();
		}
	}
	
	
	
}
 
开发者ID:wjggwm,项目名称:webside,代码行数:20,代码来源:RedisShiroCache.java

示例2: get

import org.apache.shiro.cache.CacheException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public V get(K key) throws CacheException {
	if (key == null) {
		return null;
	}

	V v = null;
	HttpServletRequest request = Servlets.getRequest();
	if (request != null) {
		v = (V) request.getAttribute(cacheKeyName);
		if (v != null) {
			return v;
		}
	}

	V value = null;
	value = (V) getSession().getAttribute(cacheKeyName);
	logger.debug("get {} {} {}", cacheKeyName, key, request != null ? request.getRequestURI() : "");

	if (request != null && value != null) {
		request.setAttribute(cacheKeyName, value);
	}
	return value;
}
 
开发者ID:funtl,项目名称:framework,代码行数:26,代码来源:SessionCacheManager.java

示例3: put

import org.apache.shiro.cache.CacheException; //导入依赖的package包/类
@Override
public V put(K key, V value) throws CacheException {
	if (key == null) {
		return null;
	}

	Jedis jedis = null;
	try {
		jedis = JedisUtils.getResource();
		jedis.hset(JedisUtils.getBytesKey(cacheKeyName), JedisUtils.getBytesKey(key), JedisUtils.toBytes(value));
		logger.debug("put {} {} = {}", cacheKeyName, key, value);
	} catch (Exception e) {
		logger.error("put {} {}", cacheKeyName, key, e);
	} finally {
		JedisUtils.returnResource(jedis);
	}
	return value;
}
 
开发者ID:funtl,项目名称:framework,代码行数:19,代码来源:JedisCacheManager.java

示例4: remove

import org.apache.shiro.cache.CacheException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public V remove(K key) throws CacheException {
	V value = null;
	Jedis jedis = null;
	try {
		jedis = JedisUtils.getResource();
		value = (V) JedisUtils.toObject(jedis.hget(JedisUtils.getBytesKey(cacheKeyName), JedisUtils.getBytesKey(key)));
		jedis.hdel(JedisUtils.getBytesKey(cacheKeyName), JedisUtils.getBytesKey(key));
		logger.debug("remove {} {}", cacheKeyName, key);
	} catch (Exception e) {
		logger.warn("remove {} {}", cacheKeyName, key, e);
	} finally {
		JedisUtils.returnResource(jedis);
	}
	return value;
}
 
开发者ID:funtl,项目名称:framework,代码行数:18,代码来源:JedisCacheManager.java

示例5: put

import org.apache.shiro.cache.CacheException; //导入依赖的package包/类
public Object put(final String key, final Object value) throws CacheException {
	final String realKey = key(key);
	return redisTemplate.execute(new SessionCallback<Object>(){
		public Object execute(RedisOperations operations) throws DataAccessException {
			operations.multi();//事务开启
			operations.opsForValue().get(realKey);
			if(cacheExpire){
				operations.opsForValue().set(realKey, value, cacheExpireSeconds, TimeUnit.SECONDS);
			}else{
				operations.opsForValue().set(realKey, value);
			}
			List<Object> results = operations.exec(); //结束事务
			return results.get(0);
		}
	});
}
 
开发者ID:penggle,项目名称:xproject,代码行数:17,代码来源:RedisCache.java

示例6: getCache

import org.apache.shiro.cache.CacheException; //导入依赖的package包/类
@Override
public <K, V> Cache<K, V> getCache(String name) throws CacheException {
    logger.debug("获取名称为: " + name + " 的RedisCache实例");

    Cache c = caches.get(name);

    if (c == null) {

        // create a new cache instance
        c = new RedisCache<K, V>(jedisClient, keyPrefix);

        // add it to the cache collection
        caches.put(name, c);
    }
    return c;
}
 
开发者ID:babymm,项目名称:mumu,代码行数:17,代码来源:RedisCacheManager.java

示例7: get

import org.apache.shiro.cache.CacheException; //导入依赖的package包/类
@Override
public V get(K key) throws CacheException {
    logger.debug("根据key从Redis中获取对象 key [" + key + "]");
    try {
        if (key == null) {
            return null;
        }else{
            byte[] rawValue = cache.get(getByteKey(key));
            V value = (V)JavaSerializeUtil.deserialize(rawValue);
            return value;
        }
    } catch (Throwable t) {
        throw new CacheException(t);
    }

}
 
开发者ID:babymm,项目名称:mumu,代码行数:17,代码来源:RedisCache.java

示例8: get

import org.apache.shiro.cache.CacheException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public V get(K key) throws CacheException {
	if (key == null){
		return null;
	}
	
	V v = null;
	HttpServletRequest request = Servlets.getRequest();
	if (request != null){
		v = (V)request.getAttribute(cacheKeyName);
		if (v != null){
			return v;
		}
	}
	
	V value = null;
	value = (V)getSession().getAttribute(cacheKeyName);
	logger.debug("get {} {} {}", cacheKeyName, key, request != null ? request.getRequestURI() : "");
	
	if (request != null && value != null){
		request.setAttribute(cacheKeyName, value);
	}
	return value;
}
 
开发者ID:egojit8,项目名称:easyweb,代码行数:26,代码来源:SessionCacheManager.java

示例9: put

import org.apache.shiro.cache.CacheException; //导入依赖的package包/类
@Override
public V put(K key, V value) throws CacheException {
	if (key == null){
		return null;
	}
	
	Jedis jedis = null;
	try {
		jedis = JedisUtils.getResource();
		jedis.hset(JedisUtils.getBytesKey(cacheKeyName), JedisUtils.getBytesKey(key), JedisUtils.toBytes(value));
		logger.debug("put {} {} = {}", cacheKeyName, key, value);
	} catch (Exception e) {
		logger.error("put {} {}", cacheKeyName, key, e);
	} finally {
		JedisUtils.returnResource(jedis);
	}
	return value;
}
 
开发者ID:egojit8,项目名称:easyweb,代码行数:19,代码来源:JedisCacheManager.java

示例10: remove

import org.apache.shiro.cache.CacheException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public V remove(K key) throws CacheException {
	V value = null;
	Jedis jedis = null;
	try {
		jedis = JedisUtils.getResource();
		value = (V)JedisUtils.toObject(jedis.hget(JedisUtils.getBytesKey(cacheKeyName), JedisUtils.getBytesKey(key)));
		jedis.hdel(JedisUtils.getBytesKey(cacheKeyName), JedisUtils.getBytesKey(key));
		logger.debug("remove {} {}", cacheKeyName, key);
	} catch (Exception e) {
		logger.warn("remove {} {}", cacheKeyName, key, e);
	} finally {
		JedisUtils.returnResource(jedis);
	}
	return value;
}
 
开发者ID:egojit8,项目名称:easyweb,代码行数:18,代码来源:JedisCacheManager.java

示例11: put

import org.apache.shiro.cache.CacheException; //导入依赖的package包/类
public V put(K k, V v) throws CacheException {
  trace("Putting object", k);

  V previousValue = null;

  while (true) {
    previousValue = cache.get(k);
    if (previousValue == null) {
      if (cache.putIfAbsent(k, v) == null) {
        break;
      }
    } else {
      if (cache.replace(k, v) != null) {
        break;
      }
    }
  }

  return previousValue;
}
 
开发者ID:ehcache,项目名称:ehcache-shiro,代码行数:21,代码来源:EhcacheShiro.java

示例12: remove

import org.apache.shiro.cache.CacheException; //导入依赖的package包/类
public V remove(K k) throws CacheException {
  trace("Removing object", k);

  V previousValue = null;

  while (true) {
    previousValue = cache.get(k);
    if (previousValue == null) {
      break;
    } else {
      if (cache.remove(k, previousValue)) {
        break;
      }
    }
  }

  return previousValue;
}
 
开发者ID:ehcache,项目名称:ehcache-shiro,代码行数:19,代码来源:EhcacheShiro.java

示例13: getCache

import org.apache.shiro.cache.CacheException; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public <K, V> Cache<K, V> getCache(String name) throws CacheException {
  log.trace("Acquiring EhcacheShiro instance named [{}]", name);

  try {
    org.ehcache.Cache<Object, Object> cache = ensureCacheManager().getCache(name, Object.class, Object.class);

    if (cache == null) {
      log.info("Cache with name {} does not yet exist.  Creating now.", name);
      cache = createCache(name);
      log.info("Added EhcacheShiro named [{}]", name);
    } else {
      log.info("Using existing EhcacheShiro named [{}]", name);
    }

    return new EhcacheShiro<K, V>(cache);
  } catch (MalformedURLException e) {
    throw new CacheException(e);
  }
}
 
开发者ID:ehcache,项目名称:ehcache-shiro,代码行数:23,代码来源:EhcacheShiroManager.java

示例14: get

import org.apache.shiro.cache.CacheException; //导入依赖的package包/类
@Override
public V get(K key) throws CacheException {
    logger.debug("根据key从Redis中获取对象 key [" + key + "]");
    try {
        if (key == null) {
            return null;
        } else {
            byte[] rawValue = redisDao.getByte(key.toString());
            @SuppressWarnings("unchecked")
            V value = (V) SerializationUtils.deserialize(rawValue);
            return value;
        }
    } catch (Throwable t) {
        throw new CacheException(t);
    }

}
 
开发者ID:bill1012,项目名称:AdminEAP,代码行数:18,代码来源:RedisCache.java

示例15: clear

import org.apache.shiro.cache.CacheException; //导入依赖的package包/类
@Override
public void clear() throws CacheException {
	logger.debug("clear redis all data!");
	try {
		synchronized (this) {
			Set<byte[]> keys = cache.keys(this.keyPrefix + "*");
			if (!CollectionUtils.isEmpty(keys)) {
				for (byte[] key : keys) {
					cache.del(key);
				}
			}
		}
	} catch (Throwable t) {
		throw new CacheException(t);
	}
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:17,代码来源:RedisCache.java


注:本文中的org.apache.shiro.cache.CacheException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。