net.sf.ehcache.store
public class DiskStore extends Object implements Store
Version: $Id: DiskStore.java 155 2006-07-15 08:23:12Z gregluck $
Nested Class Summary | |
---|---|
class | DiskStore.MemoryEfficientByteArrayOutputStream
This class is designed to minimse the number of System.arraycopy(); methods
required to complete. |
Field Summary | |
---|---|
static String | AUTO_DISK_PATH_DIRECTORY_PREFIX
If the CacheManager needs to resolve a conflict with the disk path, it will create a
subdirectory in the given disk path with this prefix followed by a number. |
Constructor Summary | |
---|---|
DiskStore(Cache cache, String diskPath)
Creates a disk store.
|
Method Summary | |
---|---|
float | calculateDataFileSparseness()
The design of the layout on the data file means that there will be small gaps created when DiskElements
are reused.
|
boolean | containsKey(Object key)
An unsynchronized and very low cost check to see if a key is in the Store. |
void | dispose()
Shuts down the disk store in preparation for cache shutdown
If a VM crash happens, the shutdown hook will not run. |
void | flush()
Flush the spool if persistent, so we don't lose any data.
|
Element | get(Object key)
Gets an Element from the Disk Store.
|
String | getDataFileName() |
String | getDataFilePath() |
long | getDataFileSize() |
String | getIndexFileName() |
long | getIndexFileSize() |
Object[] | getKeyArray()
Gets an Array of the keys for all elements in the disk store.
|
Element | getQuiet(Object key)
Gets an Element from the Disk Store, without updating statistics
|
int | getSize()
Returns the current store size.
|
Status | getStatus()
Returns the store status. |
long | getTotalFileSize() |
long | getUsedDataSize()
When elements are deleted, spaces are left in the file. |
boolean | isExpiryThreadAlive()
The expiry thread is started provided the cache is not eternal
If started it will continue to run until the dispose method is called,
at which time it should be interrupted and then die.
|
boolean | isSpoolEmpty()
Whether there are any elements waiting to be spooled to disk.
|
void | put(Element element)
Puts an element into the disk store.
|
Element | remove(Object key)
Removes an item from the disk store.
|
void | removeAll()
Remove all of the elements from the store.
|
String | toString()
Returns a String representation of the |
Parameters: cache the Cache that the store is part of diskPath the directory in which to create data and index files
Returns: the sparseness, measured as the percentage of space in the Data File not used for holding data
Parameters: key The Element key
Returns: true if found. If this method return false, it means that an Element with the given key is definitely not in the MemoryStore. If it returns true, there is an Element there. An attempt to get it may return null if the Element has expired.
Throws: IOException
Returns: The element
Returns: the file name of the data file where the disk store stores data, without any path information.
Returns: the disk path, which will be dependent on the operating system
Returns: the size of the data file in bytes.
Returns: the file name of the index file, which maintains a record of elements and their addresses on the data file, without any path information.
Returns: the size of the index file, in bytes.
Returns: An Object[] of Serializable keys
UNKNOWN: SynchronizeOnNonFinalField
Returns: The element
UNKNOWN: SynchronizeOnNonFinalField
Returns: the total size of the data file and the index file, in bytes.
Returns: true if an expiryThread was created and is still alive.
Returns: false if there are elements waiting, otherwise true
UNKNOWN: SynchronizeOnNonFinalField
CacheEventListener
s they are notified of the expiry or removal
of the Element
as each is removed.