/*******************************************************************************
* Copyright (c) 2012 IBM Corporation.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v. 1.0 which accompanies this distribution.
*
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
*
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.lyo.server.oauth.core.token;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* Least recently used cache for storing OAuth tokens.
*
* @author Samuel Padgett <spadgett@us.ibm.com>
*/
public class LRUCache<K, V> extends LinkedHashMap<K, V> {
private static final long serialVersionUID = -3846345693980360667L;
private final int max;
public LRUCache(final int max) {
this.max = max;
}
@Override
protected boolean removeEldestEntry(final Map.Entry<K, V> eldest) {
return super.size() > max;
}
}