Example #1
0
  public void purge() {
    CacheEntry queueEntry = expirationQueue.peek();

    while ((queueEntry != null) && queueEntry.isExpired()) {
      super.remove(queueEntry.getKey());
      expirationQueue.remove();
      queueEntry = expirationQueue.peek();
    }
  }
  // Javadoc inherited.
  public Object perform(MethodActionEvent event) throws Throwable {

    CacheEntry entry = (CacheEntry) event.getArgument(CacheEntry.class);
    if (hasEntry) {
      Assert.assertSame(expectedKey, entry.getKey());
      Assert.assertSame(expectedValue, entry.getValue());
    } else {
      Assert.assertNull(entry);
    }

    return null;
  }
Example #3
0
  /**
   * Flush a cache entry. On completion of the flush, a <tt>CacheEntryEventType.ENTRY_FLUSHED</tt>
   * event is fired.
   *
   * @param entry The entry to flush
   * @param origin The origin of this flush event (optional)
   */
  private void flushEntry(CacheEntry entry, String origin) {
    String key = entry.getKey();

    // Flush the object itself
    entry.flush();

    if (!entry.isNew()) {
      // Update the entry's state in the map
      cacheMap.put(key, entry);
    }

    // Trigger an ENTRY_FLUSHED event. [CACHE-107] Do this for all flushes.
    if (listenerList.getListenerCount() > 0) {
      CacheEntryEvent event = new CacheEntryEvent(this, entry, origin);
      dispatchCacheEntryEvent(CacheEntryEventType.ENTRY_FLUSHED, event);
    }
  }
Example #4
0
 private void doPut(CacheEntry entry) {
   map.put(entry.getKey(), new SoftReference<CacheEntry>(entry));
 }