com.j256.ormlite.dao.LruObjectCache Maven / Gradle / Ivy
package com.j256.ormlite.dao;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
/**
* Cache for ORMLite which stores a certain number of items for each Class. Inserting an object into the cache once it
* is full will cause the least-recently-used object to be ejected. They can be injected into a dao with the
* {@link Dao#setObjectCache(ObjectCache)}.
*
*
* NOTE: If you set the capacity to be 100 then each Class will allow 100 items in the cache. If you have
* 5 classes then the cache will hold 500 objects.
*
*
* @author graywatson
*/
public class LruObjectCache implements ObjectCache {
private final int capacity;
private final ConcurrentHashMap, Map