/**
  * 从redis 同步数据到本地
  *
  * @author 杨雪令
  * @time 2016年5月18日上午11:28:48
  * @version 1.0
  */
 @SuppressWarnings({"rawtypes", "unchecked"})
 public Map<String, Object> syncFromRedis() {
   if (key == null || key.length() < 1) return null;
   Map<String, Object> paramMap = null;
   paramMap = (Map) JedisUtil.get(key);
   if (paramMap != null) {
     JedisUtil.setTimeout(key, timeout * 60);
     // 同步redis中的数据到httpSession中
     for (Map.Entry<String, Object> entry : paramMap.entrySet()) {
       httpSession.setAttribute(entry.getKey(), entry.getValue());
     }
   }
   return paramMap;
 }
 /**
  * 设置数据到redis
  *
  * @param key key
  * @param value 值
  * @author 杨雪令
  * @time 2016年5月18日上午11:46:03
  * @version 1.0
  */
 public void putToRedis(String key, Object value) {
   if (this.key == null || this.key.length() < 1) return;
   Map<String, Object> paramMap = syncFromRedis();
   if (paramMap == null) paramMap = new HashMap<String, Object>();
   paramMap.put(key, value);
   JedisUtil.set(this.key, paramMap, timeout * 60);
 }
 /**
  * 同步数据到redis
  *
  * @author 杨雪令
  * @time 2016年5月18日上午11:46:03
  * @version 1.0
  */
 public void syncToRedis() {
   if (this.key == null || this.key.length() < 1) return;
   Map<String, Object> paramMap = new HashMap<String, Object>();
   for (String valueName : httpSession.getValueNames()) {
     paramMap.put(valueName, httpSession.getAttribute(valueName));
   }
   JedisUtil.set(this.key, paramMap, timeout * 60);
 }
 /**
  * 从redis中删除数据
  *
  * @param key key
  * @author 杨雪令
  * @time 2016年5月18日上午11:46:03
  * @version 1.0
  */
 public void deleteFromRedis(String key) {
   if (this.key == null || this.key.length() < 1) return;
   Map<String, Object> paramMap = syncFromRedis();
   if (paramMap != null && paramMap.containsKey(key)) {
     paramMap.remove(key);
   }
   JedisUtil.set(this.key, paramMap, timeout * 60);
 }
 @Override
 public void invalidate() {
   if (key == null || key.length() < 1) return;
   try {
     JedisUtil.delete(key);
   } catch (Exception e) {
     logger.error("从redis删除session出错:" + e.getMessage());
   } finally {
     httpSession.invalidate();
   }
 }