All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ehcache.impl.internal.concurrent.EvictingConcurrentMap Maven / Gradle / Ivy

There is a newer version: 3.10.8
Show newest version
/*
 * Copyright Terracotta, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.ehcache.impl.internal.concurrent;

import org.ehcache.config.EvictionAdvisor;

import java.util.Collection;
import java.util.Comparator;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.ConcurrentMap;

public interface EvictingConcurrentMap extends ConcurrentMap{

  /**
   * Return the preferred entry to evict based on a sample of entries taken from the map.
   *
   * @param rndm Random implementation used to determine the sample randomly
   * @param size Number of sampled entries
   * @param prioritizer Prioritizer used to determine the best entry to evict in the sample
   * @param evictionAdvisor Can veto against the eviction of an entry
   * @return Entry to evict or null is none was found
   */
  Entry getEvictionCandidate(Random rndm, int size, Comparator prioritizer, EvictionAdvisor evictionAdvisor);

  /**
   * Returns the number of mappings. This method should be used
   * instead of {@link #size} because a ConcurrentHashMap may
   * contain more mappings than can be represented as an int. The
   * value returned is an estimate; the actual count may differ if
   * there are concurrent insertions or removals.
   *
   * @return the number of mappings
   */
  long mappingCount();

  /**
   * Remove all entries for a given hashcode (as returned by {@code key.hashCode()}).
   *
   * @param keyHash remove entries having this hashcode
   * @return the removed entries
   */
  Collection> removeAllWithHash(int keyHash);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy