org.hibernate.search.util.impl.LRUMap Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate-search-engine Show documentation
Show all versions of hibernate-search-engine Show documentation
Core of the Object/Lucene mapper, query engine and index management
/*
* Hibernate Search, full-text search for your domain model
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or .
*/
package org.hibernate.search.util.impl;
import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* Copied from Hibernate Core's org.hibernate.util.LRUMap
* A simple LRU cache that implements the Map
interface. Instances
* are not thread-safe and should be synchronized externally, for instance by
* using {@link java.util.Collections#synchronizedMap}.
*
* @author Manuel Dominguez Sarmiento
*/
public class LRUMap extends LinkedHashMap implements Serializable {
private static final long serialVersionUID = -2613234214057068628L;
private final int maxEntries;
public LRUMap(int maxEntries) {
super( maxEntries, .75f, true );
this.maxEntries = maxEntries;
}
@Override
protected boolean removeEldestEntry(Map.Entry eldest) {
return ( size() > maxEntries );
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy