net.sf.ehcache.store
Class DiskStore

java.lang.Object
  extended bynet.sf.ehcache.store.DiskStore
All Implemented Interfaces:
Store

public class DiskStore
extends java.lang.Object
implements Store

A disk cache implementation.

Version:
$Id: DiskStore.java,v 1.10 2003/12/25 00:43:11 gregluck Exp $
Author:
Adam Murdoch, Greg Luck

Field Summary
 
Fields inherited from interface net.sf.ehcache.store.Store
CACHE_HUB, DISK_CACHE, STATUS_ALIVE, STATUS_DISPOSED, STATUS_ERROR, STATUS_UNINITIALISED
 
Constructor Summary
DiskStore(Cache cache, java.lang.String diskPath)
          Creates a Disk Store with defaults.
DiskStore(Cache cache, java.lang.String diskPath, int expiryThreadInterval)
          Creates a cache.
 
Method Summary
 void dispose()
          Prepares for shutdown.
 Element get(java.io.Serializable key)
          Gets an Element from the Disk Store.
static Store getCache(java.lang.String name)
          Locates a cache, by name.
 int getCacheType()
          Returns the cache type.
 java.lang.Object[] getKeyArray()
          Gets an Array of the keys for all elements in the memory cache
 java.lang.String getName()
          Returns the cache name this disk cache is spooling for
 int getSize()
          Returns the current store size.
 int getStatus()
          Returns the cache status.
 boolean isSpoolEmpty()
          Whether there are any elements waiting to be spooled to disk.
 void put(Element entry)
          Puts an item to the cache.
 boolean remove(java.io.Serializable key)
          Removes an item from the cache.
 void removeAll()
          Removes all cached items from the cache.
 java.lang.String toString()
          Returns a String representation of the DiskStore
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DiskStore

public DiskStore(Cache cache,
                 java.lang.String diskPath)
Creates a Disk Store with defaults.

The expiry thread will run once every 5 minutes.


DiskStore

public DiskStore(Cache cache,
                 java.lang.String diskPath,
                 int expiryThreadInterval)
Creates a cache.

Method Detail

getCache

public static Store getCache(java.lang.String name)
Locates a cache, by name.


getCacheType

public int getCacheType()
Returns the cache type.

Specified by:
getCacheType in interface Store
Returns:
The cacheType value

getName

public java.lang.String getName()
Returns the cache name this disk cache is spooling for

Specified by:
getName in interface Store

getStatus

public int getStatus()
Returns the cache status.

Specified by:
getStatus in interface Store

get

public Element get(java.io.Serializable key)
            throws java.io.IOException
Gets an Element from the Disk Store.

Specified by:
get in interface Store
Returns:
The element may not be null but the value may be, as it is softly referenced. This should be checked by callers of this method.
Throws:
java.io.IOException

getKeyArray

public java.lang.Object[] getKeyArray()
Gets an Array of the keys for all elements in the memory cache

Returns:
An Object[]

getSize

public int getSize()
Returns the current store size.

Specified by:
getSize in interface Store

put

public void put(Element entry)
         throws java.io.IOException
Puts an item to the cache.

Specified by:
put in interface Store
Throws:
java.io.IOException

remove

public boolean remove(java.io.Serializable key)
               throws java.io.IOException
Removes an item from the cache.

Specified by:
remove in interface Store
Throws:
java.io.IOException

removeAll

public void removeAll()
               throws java.io.IOException
Removes all cached items from the cache.

Specified by:
removeAll in interface Store
Throws:
java.io.IOException

dispose

public void dispose()
Prepares for shutdown.

Specified by:
dispose in interface Store

isSpoolEmpty

public boolean isSpoolEmpty()
Whether there are any elements waiting to be spooled to disk.

Returns:
false if there are elements waiting, otherwise true

toString

public java.lang.String toString()
Returns a String representation of the DiskStore