示例#1
0
 public boolean remove(int pos) {
   boolean result = lru.remove(pos);
   if (!result) {
     result = fifo.remove(pos);
   }
   recentlyUsed.remove(pos);
   return result;
 }
示例#2
0
  private void cache(String dn, Set<String> indexes, Cache cache) {
    rwlock.writeLock().lock();
    String cacheName = cacheToName.get(cache);

    try {
      for (String s : indexes) {
        Set<String> setDNs = (Set<String>) cache.get(s);
        if (setDNs == null) {
          setDNs = new HashSet<String>();
          cache.put(s, setDNs);
          setDNs.add(dn);
        } else {
          if (!CacheTaboo.isTaboo(cacheName, s)) {
            if (setDNs.size() >= CACHE_BUCKET_LIMIT) {
              CacheTaboo.taboo(cacheName, s);
              cache.remove(s);
            } else {
              setDNs.add(dn);
            }
          }
        }
      }
    } finally {
      rwlock.writeLock().unlock();
    }
  }
  @Override
  @Nullable
  public Entry get(@Nonnull Key key) {
    if (cache != null) {
      synchronized (this) {
        final Entry entry = cache.get(key);
        if (entry == null) {
          Billing.debug(TAG, "Key=" + key + " is not in the cache");
          return null;
        }
        final long now = currentTimeMillis();
        if (now >= entry.expiresAt) {
          Billing.debug(
              TAG,
              "Key="
                  + key
                  + " is in the cache but was expired at "
                  + entry.expiresAt
                  + ", now is "
                  + now);
          cache.remove(key);
          return null;
        }
        Billing.debug(TAG, "Key=" + key + " is in the cache");
        return entry;
      }
    }

    return null;
  }
 @Override
 public void remove(@Nonnull Key key) {
   if (cache != null) {
     synchronized (this) {
       Billing.debug(TAG, "Removing entry with key=" + key + " from the cache");
       cache.remove(key);
     }
   }
 }
示例#5
0
  /**
   * Deletes a group from the system.
   *
   * @param group the group to delete.
   */
  public void deleteGroup(Group group) {
    // Fire event.
    GroupEventDispatcher.dispatchEvent(
        group, GroupEventDispatcher.EventType.group_deleting, Collections.emptyMap());

    // Delete the group.
    provider.deleteGroup(group.getName());

    // Expire all relevant caches.
    groupCache.remove(group.getName());
  }
  private void discardInstance(ThreadContext threadContext) {
    Object primaryKey = threadContext.getPrimaryKey();
    if (primaryKey == null) {
      return;
    }

    Instance instance = checkedOutInstances.remove(primaryKey);
    cache.remove(primaryKey);
    if (instance.creationalContext != null) {
      instance.creationalContext.release();
    }
  }
示例#7
0
 public CacheObject get(int pos) {
   CacheObject r = lru.find(pos);
   if (r != null) {
     return r;
   }
   r = fifo.find(pos);
   if (r != null && !r.isStream()) {
     if (recentlyUsed.get(pos) != null) {
       if (lastUsed != pos) {
         fifo.remove(pos);
         lru.put(r);
       }
     } else {
       recentlyUsed.put(pos, this);
     }
     lastUsed = pos;
   }
   return r;
 }
示例#8
0
 /**
  * 清除缓冲中的某个数据
  *
  * @param name
  * @param key
  */
 public static final void justEvict(String name, Serializable key) {
   if (name != null && key != null) {
     Cache cache = getCache(name);
     if (cache != null) cache.remove(key);
   }
 }
示例#9
0
 public void removeObect(String skey) {
   if (skey == null) return;
   cache.remove(skey);
   Debug.logVerbose(
       "[JdonFramework]<-cache->remove the object of " + skey + " from cache", module);
 }
示例#10
0
 /**
  * {@inheritDoc}
  *
  * @see java.util.Map#remove(java.lang.Object)
  */
 public Object remove(final Object key) {
   _log.debug(getType() + ".remove(" + key + ") [" + getName() + "]");
   return _cache.remove(key);
 }
示例#11
0
 public boolean remove(int pos) {
   boolean result = baseCache.remove(pos);
   result |= map.remove(pos) != null;
   return result;
 }