Evicts while the map exceeds the maximum capacity.
356540
private void evict(Node candidate) {
    if (data.size() > maximumSize) {
      Node victim = policy.findVictim(sentinel, policyStats);
      policyStats.recordEviction();

      boolean admit = admittor.admit(candidate.key, victim.key);
      if (admit) {
        evictEntry(victim);
      } else {
        evictEntry(candidate);
      }
    } else {
      policyStats.recordOperation();
    }
  }
303431
private void trimToSize(int maxSize) {
		while (true) {
			String key;
			Bitmap value;
			synchronized (this) {
				if (size < 0 || (map.isEmpty() && size != 0)) {
					throw new IllegalStateException(getClass().getName() + ".sizeOf() is reporting inconsistent results!");
				}

				if (size <= maxSize || map.isEmpty()) {
					break;
				}

				Map.Entry<String, Bitmap> toEvict = map.entrySet().iterator().next();
				if (toEvict == null) {
					break;
				}
				key = toEvict.getKey();
				value = toEvict.getValue();
				map.remove(key);
				size -= sizeOf(key, value);
			}
		}
	}
305064
def evict(self):
        """"""
        logging.debug('Evicting cache for %r', self.cache_key)
        _clear_version_cache(self.cache_key)
        # Cause the cache key to be refreshed next time any operation is
        # run to make sure we don't act on old cached data.
        self.versioned_cache_key = None
726370
private void onMiss(long key) {
    for (int i = 0; i < gain; i++) {
      admittor.record(key);
    }

    Node node = new Node(key);
    node.appendToTail(head);
    data.put(key, node);
    evict(node);
  }
912163
public static <K, V> void clear(Map<K, V> map) {
        if (map != null) {
            map.clear();
        }
    }
1084788
public void evict() throws Exception
    {
        assertOpen();

        boolean isEmpty;
        synchronized (this)
        {
            isEmpty = pool.isEmpty();
        }
        if (!isEmpty)
        {
            if (softMinEvictableIdleTimeMillis > 0)
            {
                int numToEvict = getNumIdle() - getMinIdle();
                evict(System.currentTimeMillis() - softMinEvictableIdleTimeMillis, numToEvict);
            }
            if (minEvictableIdleTimeMillis > 0)
            {
                int numToEvict = getNumIdle();
                evict(System.currentTimeMillis() - minEvictableIdleTimeMillis, numToEvict);
            }
        }
    }
1116975
public void truncate(long newTruncationPoint) {
        if (newTruncationPoint < getFirstDrId()) {
            return;
        }
        final Iterator<Range<Long>> iter = m_map.asRanges().iterator();
        while (iter.hasNext()) {
            final Range<Long> next = iter.next();
            if (end(next) < newTruncationPoint) {
                iter.remove();
            } else if (next.contains(newTruncationPoint)) {
                iter.remove();
                m_map.add(range(newTruncationPoint, end(next)));
                return;
            } else {
                break;
            }
        }
        m_map.add(range(newTruncationPoint, newTruncationPoint));
    }
629521
private E evict() {
        switch (evictPolicy) {
            case EVICT_OLDEST:
                return deque.pollFirst();
            case EVICT_NEWEST:
                return deque.pollLast();
            default:
                throw new IllegalStateException("Illegal evict policy: " + evictPolicy);
        }

    }
221241
private Socket evictOldest() {
    Iterator<Entry<SocketAddress, Socket>> iter = 
        multimap.entries().iterator();
    if (!iter.hasNext()) {
      throw new IllegalArgumentException("Cannot evict from empty cache!");
    }
    
    Entry<SocketAddress, Socket> entry = iter.next();
    iter.remove();
    return entry.getValue();
  }
805538
protected synchronized void evictStaleEntries() {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            int size = primaryTable.size() + secondaryTable.size() + tertiaryTable.size();
            Tr.debug(tc, "The current cache size is " + size + "( " + primaryTable.size() + ", " + secondaryTable.size() + ", " + tertiaryTable.size() + ")");
        }

        tertiaryTable = secondaryTable;
        secondaryTable = primaryTable;
        primaryTable = Collections.synchronizedMap(new BoundedHashMap(this.entryLimit));

    }
59918
void evictCache(Path hdfsPath) throws IOException {
    CacheEntry c = cacheMap.remove(hdfsPath);
    if (c != null) {
      cacheSize.addAndGet(-c.entrySize);
      if (evictionIface != null) {
        evictionIface.evictCache(c.hdfsPath, c.localPath, c.entrySize);
      }
      localMetrics.numEvict++;
      if (LOG.isDebugEnabled()) {
        LOG.debug("LookasideCache removed path:" + hdfsPath +
                  " freed up size: " + c.entrySize);
      }
    }
  }
1279095
private void destroyPartitionsAndMapContainer(MapContainer mapContainer) {
        final List<LocalRetryableExecution> executions = new ArrayList<>();

        for (PartitionContainer container : partitionContainers) {
            final MapPartitionDestroyOperation op = new MapPartitionDestroyOperation(container, mapContainer);
            executions.add(InvocationUtil.executeLocallyWithRetry(nodeEngine, op));
        }

        for (LocalRetryableExecution execution : executions) {
            try {
                if (!execution.awaitCompletion(DESTROY_TIMEOUT_SECONDS, TimeUnit.SECONDS)) {
                    logger.warning("Map partition was not destroyed in expected time, possible leak");
                }
            } catch (InterruptedException e) {
                currentThread().interrupt();
                nodeEngine.getLogger(getClass()).warning(e);
            }
        }
    }
700176
protected synchronized void evictStaleEntries() {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            int size = primaryTable.size() + secondaryTable.size() + tertiaryTable.size();
            Tr.debug(tc, "The current cache size is " + size + "( " + primaryTable.size() + ", " + secondaryTable.size() + ", " + tertiaryTable.size() + ")");
        }

        ConcurrentHashMap<Object, Object> victims = tertiaryTable;

        tertiaryTable = secondaryTable;
        secondaryTable = primaryTable;
        primaryTable = new ConcurrentHashMap<Object, Object>((minSize > secondaryTable.size()) ? minSize : secondaryTable.size());

        if (victims.isEmpty() == false) {
            List<Object> evictedValues = new ArrayList<Object>();
            Iterator<Object> iterator = victims.values().iterator();
            while (iterator.hasNext()) {
                Entry entry = (Entry) iterator.next();
                if (entry.value != null) {
                    evictedValues.add(entry.value);
                }
            }

            for (CacheEvictionListener evictionCallback : cacheEvictionListenerSet) {
                evictionCallback.evicted(evictedValues);
            }
        }
    }
1025453
private FileEntry evict() {
      if (configuration.maxEntries() > 0) {
         synchronized (entries) {
            if (entries.size() > configuration.maxEntries()) {
               Iterator<FileEntry> it = entries.values().iterator();
               FileEntry fe = it.next();
               it.remove();
               return fe;
            }
         }
      }
      return null;
   }
68936
@Override
  public boolean removeEldestEntry(Map.Entry eldest) {
    boolean mustBeRemoved = this.size() > maxSize;

    if (mustBeRemoved) {
      ServerPrepareResult serverPrepareResult = ((ServerPrepareResult) eldest.getValue());
      serverPrepareResult.setRemoveFromCache();
      if (serverPrepareResult.canBeDeallocate()) {
        try {
          protocol.forceReleasePrepareStatement(serverPrepareResult.getStatementId());
        } catch (SQLException e) {
          //eat exception
        }
      }
    }
    return mustBeRemoved;
  }
1365742
@Trivial
    protected synchronized void evictStaleEntries() {
/*
 * final String METHODNAME = "evictStaleEntries";
 * if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
 * int size = primaryTable.size() + secondaryTable.size() + tertiaryTable.size();
 * Tr.debug(tc, METHODNAME + " The current cache size is " + size + "( " + primaryTable.size() + ", " + secondaryTable.size() + ", " + tertiaryTable.size() + ")");
 * }
 */

        // log only when we evict the last table
        if (!tertiaryTable.isEmpty()) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "evictStaleEntries Evicting tertiaryTable cache " + cacheName + ", size is " + tertiaryTable.size());
            }
        }
        tertiaryTable = secondaryTable;
        secondaryTable = primaryTable;
        primaryTable = new ConcurrentHashMap<String, Object>((minSize > secondaryTable.size()) ? minSize : secondaryTable.size());
    }
511548
def clear(self, omit_item_evicted=False):
        """"""
        if not omit_item_evicted:
            items = self._dict.items()
            for key, value in items:
                self._evict_item(key, value)
        self._dict.clear()