org.ldaptive.cache
Class LRUCache<Q extends SearchRequest>

java.lang.Object
  extended by org.ldaptive.cache.LRUCache<Q>
Type Parameters:
Q - type of search request
All Implemented Interfaces:
Cache<Q>

public class LRUCache<Q extends SearchRequest>
extends Object
implements Cache<Q>

Least-Recently-Used cache implementation. Leverages a LinkedHashMap.

Version:
$Revision: 2885 $ $Date: 2014-02-05 16:28:49 -0500 (Wed, 05 Feb 2014) $
Author:
Middleware Services

Constructor Summary
LRUCache(int size, long timeToLive, long interval)
          Creates a new LRU cache.
 
Method Summary
 void clear()
          Removes all data from this cache.
 void close()
          Frees any resources associated with this cache.
 SearchResult get(Q request)
          Returns the ldap result for the supplied request.
 void put(Q request, SearchResult result)
          Stores the ldap result for the supplied request.
 int size()
          Returns the number of items in this cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LRUCache

public LRUCache(int size,
                long timeToLive,
                long interval)
Creates a new LRU cache.

Parameters:
size - number of results to cache
timeToLive - in seconds that results should stay in the cache
interval - in seconds to enforce timeToLive
Method Detail

clear

public void clear()
Removes all data from this cache.


get

public SearchResult get(Q request)
Returns the ldap result for the supplied request.

Specified by:
get in interface Cache<Q extends SearchRequest>
Parameters:
request - to find ldap result with
Returns:
ldap result

put

public void put(Q request,
                SearchResult result)
Stores the ldap result for the supplied request.

Specified by:
put in interface Cache<Q extends SearchRequest>
Parameters:
request - used to find ldap result
result - found with request

size

public int size()
Returns the number of items in this cache.

Returns:
size of this cache

close

public void close()
Frees any resources associated with this cache.



Copyright © 2003-2017 Virginia Tech. All Rights Reserved.