Пример #1
0
 public Object fetchObject(String skey) {
   Debug.logVerbose("[JdonFramework]<-cache->try to get cache: " + skey, module);
   CacheableWrapper cw = (CacheableWrapper) cache.get(skey);
   if (cw != null) {
     Debug.logVerbose("[JdonFramework]<-cache->got it, hashcode=" + cw.hashCode(), module);
     return cw.getCachedValue();
   } else return null;
 }
Пример #2
0
 /**
  * 清除缓存中该dataKey的相关所有缓存数据 当该dataKey相关的数据增删改时,调用本方法。以便及时清除缓存。
  *
  * <p>dataKey是数据的ID,如ProductId , ItemId等
  *
  * @param dataKey
  * @param formName
  */
 public void removeCache(Object dataKey) {
   if (dataKey == null) return;
   try {
     for (Object o : cache.keySet()) {
       String key = (String) o;
       Object cachedValue = (Object) cache.get(key);
       if (cachedValue instanceof CacheableWrapper) {
         CacheableWrapper cw = (CacheableWrapper) cachedValue;
         if (cw.getCachedValueKey().equals(dataKey.toString())) removeObect(key);
       }
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
 }