コード例 #1
0
 /**
  * 从缓存中删除字符数据
  *
  * @param cachedKey
  * @param discard
  */
 protected void del2CachedSet(String cachedKey, String discard) {
   Object cachedValue = cache.get(cachedKey, true);
   if (cachedValue != null && (cachedValue instanceof List)) {
     ((List<String>) cachedValue).remove(discard);
   }
   cache.put(cachedKey, cachedValue);
 }
コード例 #2
0
 /**
  * 将对象数据添加到cache
  *
  * @param cachedKey
  * @param addition
  */
 protected void add2CachedSet(String cachedKey, Object addition) {
   Object cachedValue = cache.get(cachedKey, true);
   if (cachedValue == null || !(cachedValue instanceof List)) {
     cachedValue = new ArrayList<Object>();
   }
   ((List<Object>) cachedValue).add(addition);
   cache.put(cachedKey, cachedValue);
 }
コード例 #3
0
 /**
  * 从缓存中删除整数数据
  *
  * @param cachedKey
  * @param discard
  */
 protected void del2CachedSet(String cachedKey, Integer discard) {
   Object cachedValue = cache.get(cachedKey, true);
   if (cachedValue != null && (cachedValue instanceof List)) {
     ((List<Integer>) cachedValue).remove(discard);
   } else {
     cachedValue = new ArrayList<>();
   }
   cache.put(cachedKey, cachedValue);
 }
コード例 #4
0
  /**
   * 将字符数据添加到cache
   *
   * @param cachedKey
   * @param addition
   */
  protected void add2CachedSet(String cachedKey, String addition) {
    List<String> valueLst = null;
    Object cachedValue = cache.get(cachedKey, true);
    if (cachedValue == null || !(cachedValue instanceof List)) {
      valueLst = new ArrayList<String>();
    } else {
      valueLst = (List<String>) cachedValue;
    }

    if (!valueLst.contains(addition)) {
      valueLst.add(addition);
    }
    cache.put(cachedKey, valueLst);
  }