package de.ivu.elect.business.personenregister.control;

import java.util.LinkedHashMap;
import java.util.Map;

import de.ivu.elect.business.personenregister.entity.PersonenRegisterCacheRequest;
import de.ivu.elect.business.personenregister.entity.PersonenRegisterCacheResponse;

public class LruPersonenRegisterCacheMap extends LinkedHashMap<PersonenRegisterCacheRequest, PersonenRegisterCacheResponse> {
  private static final long serialVersionUID = 1L;

  private final int cacheSize;

  public LruPersonenRegisterCacheMap(int cacheSize) {
    super(cacheSize + 1, .75F, true);
    this.cacheSize = cacheSize;
  }

  @Override
  protected boolean removeEldestEntry(Map.Entry<PersonenRegisterCacheRequest, PersonenRegisterCacheResponse> eldest) {
    return size() > cacheSize;
  }
}
