Top Description Methods
net.sf.ehcache.distribution

public Interface CachePeer

extends Remote
Known Direct Implementers
net.sf.ehcache.distribution.RMICachePeer
Imports
net.sf.ehcache.Element, java.io.Serializable, java.rmi.Remote, .RemoteException, java.util.List

An interface for a cache peer to which updates are made remotely. The distribution mechanism is meant to be pluggable. The requirements of RMI force this interface to exten Remote and throw RemoteException.

It is acknowledged that not all implementations will use Remote. Remote is just a marker interface like Serializable, so nothing specific is required.

Non-RMI implementations should be able to use this interface. Implementations not using RMI should

Author
Greg Luck
Version
$Id: CachePeer.java 10789 2018-04-26 02:08:13Z adahanne $

Method Summary

Modifier and TypeMethod and Description
public List<E>

Returns:

a list of Elements. If an element was not found or null, it will not be in the list.
getElements
(List<E>
a list of serializable values which represent keys
keys
)

Gets a list of elements from the cache, for a list of keys, without updating Element statistics.

public String

Returns:

a String representation of the GUID
getGuid
()

Gets the globally unique id for the underlying Cache instance.

public List<E>

Returns:

a list of Object keys
getKeys
()

Returns a list of all elements in the cache, whether or not they are expired.

public String
getName()

Gets the cache name.

public Element

Returns:

the element, or null, if it does not exist.
getQuiet
(Serializable
a serializable value
key
)

Gets an element from the cache, without updating Element statistics.

public String

Returns:

the URL as a string
getUrl
()

The URL for the remote replicator to connect.

public String
getUrlBase()

The URL base for the remote replicator to connect.

public void
put(Element element)

Put an element in the cache.

public boolean

Returns:

true if the element was removed, false if it was not found in the cache
remove
(Serializable key)

Removes an net.sf.ehcache.Element from the Cache.

public void
removeAll()

Removes all cached items.

public void
send(List<E>
a list of type EventMessage
eventMessages
)

Send the cache peer with an ordered list of EventMessages.

Method Detail

getElementsback to summary
public List<E> getElements(List<E> keys) throws RemoteException

Gets a list of elements from the cache, for a list of keys, without updating Element statistics. Time to idle lifetimes are therefore not affected.

Cache statistics are still updated.

Parameters
keys:List<E>

a list of serializable values which represent keys

Returns:List<E>

a list of Elements. If an element was not found or null, it will not be in the list.

getGuidback to summary
public String getGuid() throws RemoteException

Gets the globally unique id for the underlying Cache instance.

Returns:String

a String representation of the GUID

getKeysback to summary
public List<E> getKeys() throws RemoteException

Returns a list of all elements in the cache, whether or not they are expired.

The returned keys are unique and can be considered a set.

The List returned is not live. It is a copy.

The time taken is O(n). On a single cpu 1.8Ghz P4, approximately 8ms is required for each 1000 entries.

Returns:List<E>

a list of Object keys

getNameback to summary
public String getName() throws RemoteException

Gets the cache name.

getQuietback to summary
public Element getQuiet(Serializable key) throws RemoteException

Gets an element from the cache, without updating Element statistics. Cache statistics are still updated.

Parameters
key:Serializable

a serializable value

Returns:Element

the element, or null, if it does not exist.

getUrlback to summary
public String getUrl() throws RemoteException

The URL for the remote replicator to connect. The value will only have meaning for a specific implementation of replicator and remote peer.

This method is not meant to be used remotely. The replicator already needs to know this. It has to throw RemoteException to comply with RMI requirements

Returns:String

the URL as a string

getUrlBaseback to summary
public String getUrlBase() throws RemoteException

The URL base for the remote replicator to connect. The value will have meaning only to a specific implementation of replicator and remote peer.

putback to summary
public void put(Element element) throws IllegalArgumentException, IllegalStateException, RemoteException

Put an element in the cache.

Resets the access statistics on the element, which would be the case if it has previously been gotten from a cache, and is now being put back.

Exceptions
IllegalArgumentException:
if the element is null
IllegalStateException:
if the cache is not net.sf.ehcache.Status#STATUS_ALIVE
removeback to summary
public boolean remove(Serializable key) throws IllegalStateException, RemoteException

Removes an net.sf.ehcache.Element from the Cache. This also removes it from any stores it may be in.

Returns:boolean

true if the element was removed, false if it was not found in the cache

Exceptions
IllegalStateException:
if the cache is not net.sf.ehcache.Status#STATUS_ALIVE
removeAllback to summary
public void removeAll() throws RemoteException, IllegalStateException

Removes all cached items.

Exceptions
IllegalStateException:
if the cache is not net.sf.ehcache.Status#STATUS_ALIVE
sendback to summary
public void send(List<E> eventMessages) throws RemoteException

Send the cache peer with an ordered list of EventMessages.

This enables multiple messages to be delivered in one network invocation.

Parameters
eventMessages:List<E>

a list of type EventMessage