Example #1
0
 /**
  * Saves the key to our fast access AtomicReferenceArray
  *
  * @param elementJustAdded the new element
  */
 protected void saveKey(Element elementJustAdded) {
   int index = incrementIndex();
   Object key = keyArray.get(index);
   Element oldElement = null;
   if (key != null) {
     oldElement = (Element) map.get(key);
   }
   if (oldElement != null) {
     if (policy.compare(oldElement, elementJustAdded)) {
       // new one will always be more desirable for eviction as no gets yet, unless no gets on old
       // one.
       // Consequence of this algorithm
       keyArray.set(index, elementJustAdded.getObjectKey());
     }
   } else {
     keyArray.set(index, elementJustAdded.getObjectKey());
   }
 }