ehcache

net.sf.ehcache.distribution
Interface CachePeer

All Superinterfaces:
java.rmi.Remote
All Known Implementing Classes:
JGroupManager, RMICachePeer

public interface CachePeer
extends java.rmi.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 704 2008-07-13 00:17:52Z gregluck $
Author:
Greg Luck

Method Summary
 java.util.List getElements(java.util.List keys)
          Gets a list of elements from the cache, for a list of keys, without updating Element statistics.
 java.lang.String getGuid()
          Gets the globally unique id for the underlying Cache instance.
 java.util.List getKeys()
          Returns a list of all elements in the cache, whether or not they are expired.
 java.lang.String getName()
          Gets the cache name.
 Element getQuiet(java.io.Serializable key)
          Gets an element from the cache, without updating Element statistics.
 java.lang.String getUrl()
          The URL for the remote replicator to connect.
 java.lang.String getUrlBase()
          The URL base for the remote replicator to connect.
 void put(Element element)
          Put an element in the cache.
 boolean remove(java.io.Serializable key)
          Removes an Element from the Cache.
 void removeAll()
          Removes all cached items.
 void send(java.util.List eventMessages)
          Send the cache peer with an ordered list of EventMessages.
 

Method Detail

put

void put(Element element)
         throws java.lang.IllegalArgumentException,
                java.lang.IllegalStateException,
                java.rmi.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.

Parameters:
element -
Throws:
java.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
java.lang.IllegalArgumentException - if the element is null
java.rmi.RemoteException

remove

boolean remove(java.io.Serializable key)
               throws java.lang.IllegalStateException,
                      java.rmi.RemoteException
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:
java.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
java.rmi.RemoteException

removeAll

void removeAll()
               throws java.rmi.RemoteException,
                      java.lang.IllegalStateException
Removes all cached items.

Throws:
java.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
java.rmi.RemoteException

send

void send(java.util.List eventMessages)
          throws java.rmi.RemoteException
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
Throws:
java.rmi.RemoteException

getName

java.lang.String getName()
                         throws java.rmi.RemoteException
Gets the cache name.

Throws:
java.rmi.RemoteException

getGuid

java.lang.String getGuid()
                         throws java.rmi.RemoteException
Gets the globally unique id for the underlying Cache instance.

Returns:
a String representation of the GUID
Throws:
java.rmi.RemoteException

getUrl

java.lang.String getUrl()
                        throws java.rmi.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:
the URL as a string
Throws:
java.rmi.RemoteException

getUrlBase

java.lang.String getUrlBase()
                            throws java.rmi.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.

Throws:
java.rmi.RemoteException

getKeys

java.util.List getKeys()
                       throws java.rmi.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:
a list of Object keys
Throws:
java.rmi.RemoteException

getQuiet

Element getQuiet(java.io.Serializable key)
                 throws java.rmi.RemoteException
Gets an element from the cache, without updating Element statistics. Cache statistics are still updated.

Parameters:
key - a serializable value
Returns:
the element, or null, if it does not exist.
Throws:
java.rmi.RemoteException

getElements

java.util.List getElements(java.util.List keys)
                           throws java.rmi.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 - a list of serializable values which represent keys
Returns:
a list of Elements. If an element was not found or null, it will not be in the list.
Throws:
java.rmi.RemoteException

ehcache