예제 #1
0
  /**
   * Using this rather than {@link #add} will let you cache anything you please, even objects (like
   * connections to servers) that are not inherently {@link
   * edu.uiuc.ncsa.security.core.Identifiable}.
   *
   * @param key
   * @param value
   * @return
   */
  public CachedObject put(Identifier key, CachedObject value) {
    // issue is that the sorted list is a list -- adding the same cached value
    // repeatedly will result in duplicates. The real cache vets these by key.
    // It is entirely possible that a user will add a new cached object that will replace
    // a currently cached object, effectively changing how the retention policy will work with
    // it.

    CachedObject oldCO = getTheRealCache().get(key);
    if (oldCO == null) {
      // it's new
      getTheRealCache().put(key, value);
      getSortedList().add(value);

    } else {
      oldCO.setTimestamp(value.getTimestamp());
    }
    return oldCO;
  }