net.sf.ehcache.distribution

Interface CachePeer

public interface CachePeer extends Remote

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

Version: $Id: CachePeer.java 52 2006-04-24 14:50:03Z gregluck $

Author: Greg Luck

Method Summary
StringgetGuid()
Gets the globally unique id for the underlying Cache instance.
StringgetName()
Gets the cache name.
StringgetUrl()
The URL for the remote replicator to connect.
StringgetUrlBase()
The URL base for the remote replicator to connect.
voidput(Element element)
Put an element in the cache.
booleanremove(Serializable key)
Removes an Element from the Cache.
voidremoveAll()
Removes all cached items.
voidsend(List eventMessages)
Send the cache peer with an ordered list of EventMessages.

Method Detail

getGuid

public String getGuid()
Gets the globally unique id for the underlying Cache instance.

Returns: a String representation of the GUID

Throws: RemoteException

UNKNOWN: UnneededThrows

getName

public String getName()
Gets the cache name.

UNKNOWN: UnneededThrows

getUrl

public String getUrl()
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: the URL as a string

UNKNOWN: UnneededThrows

getUrlBase

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

UNKNOWN: UnneededThrows

put

public void put(Element element)
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.

Parameters: element

Throws: IllegalStateException if the cache is not STATUS_ALIVE IllegalArgumentException if the element is null

remove

public boolean remove(Serializable key)
Removes an Element from the Cache. This also removes it from any stores it may be in.

Parameters: key

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

Throws: IllegalStateException if the cache is not STATUS_ALIVE

UNKNOWN: UnneededThrows,UnusedReturnValue

removeAll

public void removeAll()
Removes all cached items.

Throws: IllegalStateException if the cache is not STATUS_ALIVE

send

public void send(List eventMessages)
Send the cache peer with an ordered list of EventMessages.

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

Parameters: eventMessages a list of type EventMessage