src.jptools.cache.ISetCache Maven / Gradle / Ivy
/*
* ISetCache.java
*
* Copyright by jptools, all rights reserved.
*/
package jptools.cache;
import jptools.util.temporality.IValidityRange;
/**
* Defines the set cache API
*
* @author Meier Patrick
* @version $Revision: 1.5 $
* @param the data type
*/
public interface ISetCache
{
/**
* Returns true if this cache contains an entry for the specified key.
*
* @param element the element to check
* @return true if this cache contains an entry for the specified key
*/
boolean contains( E element );
/**
* Adds a cache element
*
* @param element the element to add
*/
void add( E element );
/**
* Adds a cache element
*
* @param element the element to add
* @param timeout the timeout in milli seconds
*/
void add( E element, long timeout );
/**
* Adds a cache element
*
* @param element the element to add
* @param validityRange defines the validity range
*/
void add( E element, IValidityRange validityRange );
/**
* Removes a cache element.
*
* @param element the element to remove
* @return true if a previous element was removed; otherwise false
*/
boolean remove( E element );
/**
* Retrieves and removes the next element, or returns null if it is empty.
*
* @return the element or null if is its empty
*/
E poll();
/**
* Retrieves the next element, but does not remove, or returns null if it is empty.
*
* @return the element or null if is its empty
*/
E peek();
/**
* Removes all of the mappings from this cache. The cache will be empty
* after this call returns.
*/
void clear();
}