ehcache

net.sf.ehcache.distribution
Interface CachePeer

All Superinterfaces:
Remote
All Known Implementing Classes:
RMICachePeer, TransactionalRMICachePeer

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 5594 2012-05-07 16:04:31Z cdennis $
Author:
Greg Luck

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

Method Detail

put

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.

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

remove

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

removeAll

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

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

send

void send(List 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 - a list of type EventMessage
Throws:
RemoteException

getName

String getName()
               throws RemoteException
Gets the cache name.

Throws:
RemoteException

getGuid

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

Returns:
a String representation of the GUID
Throws:
RemoteException

getUrl

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:
the URL as a string
Throws:
RemoteException

getUrlBase

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.

Throws:
RemoteException

getKeys

List 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:
a list of Object keys
Throws:
RemoteException

getQuiet

Element getQuiet(Serializable key)
                 throws 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:
RemoteException

getElements

List getElements(List 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 - 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:
RemoteException

ehcache

Copyright 2001-2016, Terracotta, Inc.