ehcache

net.sf.ehcache.writer.writebehind
Class WriteBehindManager

java.lang.Object
  extended by net.sf.ehcache.writer.writebehind.WriteBehindManager
All Implemented Interfaces:
CacheWriterManager

public class WriteBehindManager
extends Object
implements CacheWriterManager

Implements a WriterManager that writes elements to a queue first and in the background sends the to the CacheWriter.

Version:
$Id: WriteBehindManager.java 7936 2013-08-08 20:36:30Z cschanck $
Author:
Geert Bevin

Constructor Summary
WriteBehindManager(Cache cache, Store store)
          Create using the given cache.
 
Method Summary
 void dispose()
          Cleans up the resources of the cache writer manager.
 long getQueueSize()
          Gets the best estimate for items in the queue still awaiting processing.
 void init(Cache cache)
          Initialize the cache writer manager.
 void put(Element element)
          Schedule a put operation for this element in the CacheWriterManager, which will call the CacheWriter when appropriate.
 void remove(CacheEntry entry)
          Schedule a remove operation for this key in the CacheWriterManager, which will call the CacheWriter when appropriate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WriteBehindManager

public WriteBehindManager(Cache cache,
                          Store store)
Create using the given cache.

Parameters:
cache - cache
Method Detail

init

public void init(Cache cache)
          throws CacheException
Initialize the cache writer manager.

This method is called when the cache writer manager is registered to a cache.

Specified by:
init in interface CacheWriterManager
Parameters:
cache - the cache with which the writer manager
Throws:
CacheException - when an exception occurs during the initialisation of the cache

put

public void put(Element element)
         throws CacheException
Schedule a put operation for this element in the CacheWriterManager, which will call the CacheWriter when appropriate.

Specified by:
put in interface CacheWriterManager
Parameters:
element - the element that should be used for the operation
Throws:
CacheException - when an exception occurs during the writing of the element

remove

public void remove(CacheEntry entry)
            throws CacheException
Schedule a remove operation for this key in the CacheWriterManager, which will call the CacheWriter when appropriate.

Specified by:
remove in interface CacheWriterManager
Parameters:
entry - the entry that should be used for the operation
Throws:
CacheException - when an exception occurs during the removal of the element

dispose

public void dispose()
Cleans up the resources of the cache writer manager.

This method is called when the manager is unregistered from a cache.

Specified by:
dispose in interface CacheWriterManager

getQueueSize

public long getQueueSize()
Gets the best estimate for items in the queue still awaiting processing. Not including elements currently processed

Returns:
the amount of elements still awaiting processing.

ehcache

Copyright 2001-2014, Terracotta, Inc.