public interface

Cache

org.apache.archiva.redback.components.cache.Cache<V, T>
Known Indirect Subclasses

Class Overview

Cache interface.

Summary

Public Methods
abstract void clear()
Clear the cache of all entries.
abstract T get(V key)
Get the value of the specified key, if it exists in the cache.
abstract int getMaxElementsInMemory()
abstract int getMaxElementsOnDisk()
abstract CacheStatistics getStatistics()
Obtain a set of Statistics about the performance of the cache.
abstract int getTimeToIdleSeconds()
abstract int getTimeToLiveSeconds()
abstract boolean hasKey(V key)
Tests to see if the provided key exists within the cache.
abstract T put(V key, T value)
Put the specified value into the cache under the provided key.
abstract void register(V key, T value)
Register the specified value into the cache under the provided key.
abstract T remove(V key)
Remove the specified key and value from the cache.
abstract void setMaxElementsInMemory(int maxElementsInMemory)
abstract void setMaxElementsOnDisk(int maxElementsOnDisk)
abstract void setTimeToIdleSeconds(int timeToIdleSeconds)
abstract void setTimeToLiveSeconds(int timeToLiveSeconds)

Public Methods

public abstract void clear ()

Clear the cache of all entries.

public abstract T get (V key)

Get the value of the specified key, if it exists in the cache.

Parameters
key the key to fetch the contents of.
Returns
  • the value of the key, or null if not found.

public abstract int getMaxElementsInMemory ()

public abstract int getMaxElementsOnDisk ()

public abstract CacheStatistics getStatistics ()

Obtain a set of Statistics about the performance of the cache.

Returns
  • the cache statistics.

public abstract int getTimeToIdleSeconds ()

public abstract int getTimeToLiveSeconds ()

public abstract boolean hasKey (V key)

Tests to see if the provided key exists within the cache.

NOTE: Due to synchronization issues, if this method returns true, a subsequent request to the get(Object) method on the same key might return null as the period of time between the 2 request might have been long enough for the underlying Cache implementation to remove the key.

Parameters
key the key to test.
Returns
  • true if the key exists.

public abstract T put (V key, T value)

Put the specified value into the cache under the provided key.

Parameters
key the key to put the value into
value the object to place into the cache.
Returns
  • the previous value for the key, or null if the key contained no value.

public abstract void register (V key, T value)

Register the specified value into the cache under the provided key.

This register(Object, Object) method is just an optimized version of the put(Object, Object) method, but does not return the previous value contained with the specified key.

Parameters
key the key to put the value into
value the object to place into the cache.

public abstract T remove (V key)

Remove the specified key and value from the cache.

Parameters
key the key to the value to remove.
Returns
  • the value of the key that was removed.

public abstract void setMaxElementsInMemory (int maxElementsInMemory)

public abstract void setMaxElementsOnDisk (int maxElementsOnDisk)

public abstract void setTimeToIdleSeconds (int timeToIdleSeconds)

public abstract void setTimeToLiveSeconds (int timeToLiveSeconds)