|
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. |
protected void |
deleteFilesInAutoGeneratedDirectory()
Delete files in the auto generated directory. |
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 |
getInternalContext()
This should not be used, and will generally return null |
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. |
int |
getTerracottaClusteredSize()
Returns nothing since a disk store isn't clustered |
long |
getTotalFileSize()
|
long |
getUsedDataSize()
When elements are deleted, spaces are left in the file. |
boolean |
isCacheCoherent()
Indicates whether this store provides a coherent view of all the elements in a cache. |
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 filesMethod Detail |
---|
public final Element get(java.lang.Object key)
Element
from the Disk Store.
get
in interface Store
public final boolean containsKey(java.lang.Object key)
containsKey
in interface Store
key
- The Element key
public final Element getQuiet(java.lang.Object key)
Element
from the Disk Store, without updating statistics
getQuiet
in interface Store
get(Object)
public final java.lang.Object[] getKeyArray()
getKeyArray
in interface Store
Serializable
keyspublic final int getSize()
getSize
in interface Store
getDataFileSize()
public final int getTerracottaClusteredSize()
getTerracottaClusteredSize
in interface Store
public long getSizeInBytes()
getSizeInBytes
in interface Store
public final Status getStatus()
getStatus
in interface Store
public final void put(Element element)
put
in interface Store
public boolean bufferFull()
bufferFull
in interface Store
public final Element remove(java.lang.Object key)
remove
in interface Store
public final void removeAll()
CacheEventListener
s they are notified of the expiry or removal
of the Element
as each is removed.
removeAll
in interface Store
public final void dispose()
dispose
in interface Store
protected void deleteFilesInAutoGeneratedDirectory()
public final void flush()
flush
in interface Store
public void expireElements()
expireElements
in interface Store
public final java.lang.String toString()
String
representation of the DiskStore
toString
in class java.lang.Object
public 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 Store
setEvictionPolicy(Policy)
public void setEvictionPolicy(Policy policy)
setEvictionPolicy
in interface Store
policy
- the new policypublic java.lang.Object getInternalContext()
getInternalContext
in interface Store
public boolean isCacheCoherent()
isCacheCoherent
in interface Store
true
if the store is coherent; or false
if the
store potentially splits the cache storage with another store or
isn't internally coherent
|
ehcache | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |