|
ehcache | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.ehcache.store.DiskStore
public class DiskStore
A disk store implementation.
As of ehcache-1.2 (v1.41 of this file) DiskStore has been changed to a mix of finer grained locking using synchronized collections and synchronizing on the whole instance, as was the case with earlier versions. The DiskStore, as of ehcache-1.2.4, supports eviction using an LFU policy, if a maximum disk store size is set. LFU uses statistics held at the Element level which survive moving between maps in the MemoryStore and DiskStores.
| Field Summary | |
|---|---|
static java.lang.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(Ehcache cache,
java.lang.String diskPath)
Creates a disk store. |
|
| Method Summary | |
|---|---|
boolean |
bufferFull()
In some circumstances data can be written so quickly to the spool that the VM runs out of memory while waiting for the spooling to disk. |
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(java.lang.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 |
expireElements()
Removes expired elements. |
void |
flush()
Flush the spool if persistent, so we don't lose any data. |
static java.lang.String |
generateUniqueDirectory()
Generates a unique directory name for use in automatically creating a diskStorePath where there is a conflict. |
Element |
get(java.lang.Object key)
Gets an Element from the Disk Store. |
java.lang.String |
getDataFileName()
Creates a file system safe data file. |
java.lang.String |
getDataFilePath()
|
long |
getDataFileSize()
|
Policy |
getEvictionPolicy()
|
java.lang.String |
getIndexFileName()
|
long |
getIndexFileSize()
|
java.lang.Object[] |
getKeyArray()
Gets an Array of the keys for all elements in the disk store. |
Element |
getQuiet(java.lang.Object key)
Gets an Element from the Disk Store, without updating statistics |
int |
getSize()
Returns the current store size in number of Elements. |
long |
getSizeInBytes()
Gets the size of the store, in bytes. |
Status |
getStatus()
Returns the store status. |
long |
getTotalFileSize()
|
long |
getUsedDataSize()
When elements are deleted, spaces are left in the file. |
boolean |
isSpoolThreadAlive()
The spool thread is started when the disk store is created. |
static net.sf.ehcache.store.DiskStore.DiskElement |
leastHit(net.sf.ehcache.store.DiskStore.DiskElement[] sampledElements,
net.sf.ehcache.store.DiskStore.DiskElement justAdded)
Finds the least hit of the sampled elements provided |
void |
put(Element element)
Puts an element into the disk store. |
Element |
remove(java.lang.Object key)
Removes an item from the disk store. |
void |
removeAll()
Remove all of the elements from the store. |
void |
setEvictionPolicy(Policy policy)
Sets the eviction policy strategy. |
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 |
| Field Detail |
|---|
public static final java.lang.String AUTO_DISK_PATH_DIRECTORY_PREFIX
| Constructor Detail |
|---|
public DiskStore(Ehcache cache,
java.lang.String diskPath)
cache - the Cache that the store is part ofdiskPath - the directory in which to create data and index files| Method Detail |
|---|
public final Element get(java.lang.Object key)
Element from the Disk Store.
get in interface Storepublic final boolean containsKey(java.lang.Object key)
containsKey in interface Storekey - The Element key
public final Element getQuiet(java.lang.Object key)
Element from the Disk Store, without updating statistics
getQuiet in interface Storepublic final java.lang.Object[] getKeyArray()
getKeyArray in interface StoreSerializable keyspublic final int getSize()
getSize in interface StoregetDataFileSize()public long getSizeInBytes()
getSizeInBytes in interface Storepublic final Status getStatus()
getStatus in interface Storepublic final void put(Element element)
put in interface Storepublic boolean bufferFull()
bufferFull in interface Storepublic final Element remove(java.lang.Object key)
remove in interface Storepublic final void removeAll()
CacheEventListeners they are notified of the expiry or removal
of the Element as each is removed.
removeAll in interface Storepublic final void dispose()
dispose in interface Storepublic final void flush()
flush in interface Storepublic void expireElements()
expireElements in interface Storepublic final java.lang.String toString()
String representation of the DiskStore
toString in class java.lang.Objectpublic static java.lang.String generateUniqueDirectory()
AUTO_DISK_PATH_DIRECTORY_PREFIX followed by "_" followed by the current
time as a long e.g. ehcache_auto_created_1149389837006public final long getTotalFileSize()
public final long getDataFileSize()
public final float calculateDataFileSparseness()
public final long getUsedDataSize()
getDataFileSize() as a measure of fragmentation.
public final long getIndexFileSize()
public final java.lang.String getDataFileName()
/ are replaced with _
so there are no unwanted side effects.
public final java.lang.String getDataFilePath()
public final java.lang.String getIndexFileName()
public final boolean isSpoolThreadAlive()
dispose() method is called,
at which time it should be interrupted and then die.
public static net.sf.ehcache.store.DiskStore.DiskElement leastHit(net.sf.ehcache.store.DiskStore.DiskElement[] sampledElements,
net.sf.ehcache.store.DiskStore.DiskElement justAdded)
sampledElements - this should be a random subset of the populationjustAdded - we never want to select the element just added. May be null.
public Policy getEvictionPolicy()
getEvictionPolicy in interface StoresetEvictionPolicy(Policy)public void setEvictionPolicy(Policy policy)
setEvictionPolicy in interface Storepolicy - the new policy
|
ehcache | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||