|
ehcache | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.ehcache.store.AbstractStore
net.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. As of ehcache-2.0, a cache can be configured with a DiskStore with multiple stripes. This enables much higher throughput.
| Nested Class Summary | |
|---|---|
static class |
DiskStore.DiskElement
A reference to an on-disk elements. |
| 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. |
| Fields inherited from interface net.sf.ehcache.store.Store |
|---|
CLUSTER_COHERENT, NODE_COHERENT |
| Constructor Summary | |
|---|---|
protected |
DiskStore(Ehcache cache,
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(Object key)
An unsynchronized and very low cost check to see if a key is in the Store. |
boolean |
containsKeyInMemory(Object key)
A check to see if a key is in the Store and is currently held in memory. |
boolean |
containsKeyOffHeap(Object key)
A check to see if a key is in the Store and is currently held off-heap. |
boolean |
containsKeyOnDisk(Object key)
A check to see if a key is in the Store and is currently held on disk. |
static DiskStore |
create(Ehcache cache,
String diskStorePath)
A factory method to create a DiskStore. |
protected void |
deleteFilesInAutoGeneratedDirectory()
Delete files in the auto generated directory. |
void |
deregistered(CacheConfiguration config)
Indicates that this listener was removed from the given configuration |
void |
diskCapacityChanged(int oldCapacity,
int newCapacity)
Indicates a change in the configurations disk store capacity |
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 String |
generateUniqueDirectory()
Generates a unique directory name for use in automatically creating a diskStorePath where there is a conflict. |
Element |
get(Object key)
Gets an DiskStore.DiskElement from the Disk Store. |
String |
getDataFileName()
Creates a file system safe data file. |
String |
getDataFilePath()
|
long |
getDataFileSize()
|
Policy |
getEvictionPolicy()
|
String |
getIndexFileName()
|
long |
getIndexFileSize()
|
Policy |
getInMemoryEvictionPolicy()
|
int |
getInMemorySize()
Returns the current local in-memory store size |
long |
getInMemorySizeInBytes()
Gets the size of the in-memory portion of the store, in bytes. |
Object |
getInternalContext()
This should not be used, and will generally return null |
List |
getKeys()
Gets an Array of the keys for all elements in the disk store. |
Object |
getMBean()
Optional implementation specific MBean exposed by the store. |
int |
getOffHeapSize()
Returns the current local off-heap store size |
long |
getOffHeapSizeInBytes()
Gets the size of the off-heap portion of the store, in bytes. |
int |
getOnDiskSize()
Returns the current local on-disk store size |
long |
getOnDiskSizeInBytes()
Gets the size of the on-disk portion of the store, in bytes. |
Element |
getQuiet(Object key)
Gets an DiskStore.DiskElement 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 |
isSpoolThreadAlive()
The spool thread is started when the disk store is created. |
static DiskStore.DiskElement |
leastHit(DiskStore.DiskElement[] sampledElements,
DiskStore.DiskElement justAdded)
Finds the least hit of the sampled elements provided |
void |
loggingChanged(boolean oldValue,
boolean newValue)
Indicates a change in the configuration for enable/disable logging |
void |
memoryCapacityChanged(int oldCapacity,
int newCapacity)
Indicates a change in the configurations memory store capacity |
boolean |
put(Element element)
Puts an element into the disk store. |
Element |
putIfAbsent(Element element)
Unsupported in DiskStore |
boolean |
putWithWriter(Element element,
CacheWriterManager writerManager)
Puts an item into the store and the cache writer manager in an atomic operation |
void |
registered(CacheConfiguration config)
Indicates that this listener was registered with the given configuration |
Element |
remove(Object key)
Removes an item from the disk store. |
void |
removeAll()
Remove all of the elements from the store. |
Element |
removeElement(Element element,
ElementValueComparator comparator)
Unsupported in DiskStore |
Element |
removeWithWriter(Object key,
CacheWriterManager writerManager)
Removes an item from the store and the cache writer manager in an atomic operation. |
Element |
replace(Element element)
Unsupported in DiskStore |
boolean |
replace(Element old,
Element element,
ElementValueComparator comparator)
Unsupported in DiskStore |
void |
setEvictionPolicy(Policy policy)
Sets the eviction policy strategy. |
void |
setInMemoryEvictionPolicy(Policy policy)
Sets the eviction policy strategy. |
void |
timeToIdleChanged(long oldTti,
long newTti)
Indicates a change in the configurations time to idle |
void |
timeToLiveChanged(long oldTtl,
long newTtl)
Indicates a change in the configurations time to live |
String |
toString()
Returns a String representation of the DiskStore |
| Methods inherited from class net.sf.ehcache.store.AbstractStore |
|---|
addStoreListener, executeQuery, getEventListenerList, getSearchAttribute, isCacheCoherent, isClusterCoherent, isNodeCoherent, removeStoreListener, setAttributeExtractors, setNodeCoherent, waitUntilClusterCoherent |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String AUTO_DISK_PATH_DIRECTORY_PREFIX
| Constructor Detail |
|---|
protected DiskStore(Ehcache cache,
String diskPath)
cache - the Cache that the store is part ofdiskPath - the directory in which to create data and index files| Method Detail |
|---|
public static DiskStore create(Ehcache cache,
String diskStorePath)
cache - diskStorePath -
public final Element get(Object key)
DiskStore.DiskElement from the Disk Store.
get in interface Storepublic final boolean containsKey(Object key)
containsKey in interface Storekey - The Element key
public final Element getQuiet(Object key)
DiskStore.DiskElement from the Disk Store, without updating statistics
getQuiet in interface Storeget(Object)public final List getKeys()
getKeys in interface StoreSerializable keyspublic final int getSize()
getSize in interface StoregetDataFileSize()public final int getTerracottaClusteredSize()
getTerracottaClusteredSize in interface Storepublic long getSizeInBytes()
public final Status getStatus()
getStatus in interface Storepublic final boolean put(Element element)
put in interface Store
public boolean putWithWriter(Element element,
CacheWriterManager writerManager)
throws CacheException
putWithWriter in interface StoreCacheExceptionpublic boolean bufferFull()
bufferFull in interface Storepublic final Element remove(Object key)
remove in interface Store
public Element removeWithWriter(Object key,
CacheWriterManager writerManager)
removeWithWriter 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 Storeprotected void deleteFilesInAutoGeneratedDirectory()
public final void flush()
flush in interface Storepublic void expireElements()
expireElements in interface Storepublic final String toString()
String representation of the DiskStore
toString in class Objectpublic static String generateUniqueDirectory()
AUTO_DISK_PATH_DIRECTORY_PREFIX followed by "_" followed by the current
time as a long e.g. ehcache_auto_created_1149389837006
public void timeToIdleChanged(long oldTti,
long newTti)
timeToIdleChanged in interface CacheConfigurationListeneroldTti - previous time to idle valuenewTti - new time to idle value
public void timeToLiveChanged(long oldTtl,
long newTtl)
timeToLiveChanged in interface CacheConfigurationListeneroldTtl - previous time to live valuenewTtl - new time to live value
public void diskCapacityChanged(int oldCapacity,
int newCapacity)
diskCapacityChanged in interface CacheConfigurationListeneroldCapacity - previous capacitynewCapacity - new capacity
public void memoryCapacityChanged(int oldCapacity,
int newCapacity)
memoryCapacityChanged in interface CacheConfigurationListeneroldCapacity - previous capacitynewCapacity - new capacity
public void loggingChanged(boolean oldValue,
boolean newValue)
loggingChanged in interface CacheConfigurationListeneroldValue - old value whether logging was enabled or notnewValue - new value whether logging was enabled or notpublic void registered(CacheConfiguration config)
registered in interface CacheConfigurationListenerpublic void deregistered(CacheConfiguration config)
deregistered in interface CacheConfigurationListenerpublic Object getMBean()
getMBean in interface Storepublic 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 String getDataFileName()
/ are replaced with _
so there are no unwanted side effects.
public final String getDataFilePath()
public final String getIndexFileName()
public final boolean isSpoolThreadAlive()
dispose() method is called,
at which time it should be interrupted and then die.
public static DiskStore.DiskElement leastHit(DiskStore.DiskElement[] sampledElements,
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()
setEvictionPolicy(Policy)public void setEvictionPolicy(Policy policy)
policy - the new policypublic Object getInternalContext()
getInternalContext in interface Storepublic boolean containsKeyInMemory(Object key)
containsKeyInMemory in interface Storekey - The Element key
public boolean containsKeyOffHeap(Object key)
containsKeyOffHeap in interface Storekey - The Element key
public boolean containsKeyOnDisk(Object key)
containsKeyOnDisk in interface Storekey - The Element key
public Policy getInMemoryEvictionPolicy()
getInMemoryEvictionPolicy in interface StoreStore.setInMemoryEvictionPolicy(Policy)public int getInMemorySize()
getInMemorySize in interface Storepublic long getInMemorySizeInBytes()
getInMemorySizeInBytes in interface Storepublic int getOffHeapSize()
getOffHeapSize in interface Storepublic long getOffHeapSizeInBytes()
getOffHeapSizeInBytes in interface Storepublic int getOnDiskSize()
getOnDiskSize in interface Storepublic long getOnDiskSizeInBytes()
getOnDiskSizeInBytes in interface Storepublic void setInMemoryEvictionPolicy(Policy policy)
setInMemoryEvictionPolicy in interface Storepolicy - the new policy
public Element putIfAbsent(Element element)
throws NullPointerException
putIfAbsent in interface Storeelement - element to be added
NullPointerException - if the element is null, or has a null key
public Element removeElement(Element element,
ElementValueComparator comparator)
throws NullPointerException
removeElement in interface Storeelement - Element to be removedcomparator - ElementValueComparator to use to compare elements
NullPointerException - if the element is null, or has a null key
public boolean replace(Element old,
Element element,
ElementValueComparator comparator)
throws NullPointerException,
IllegalArgumentException
replace in interface Storeold - Element to be test againstelement - Element to be cachedcomparator - ElementValueComparator to use to compare elements
NullPointerException - if the either Element is null or has a null key
IllegalArgumentException - if the two Element keys are non-null but not equal
public Element replace(Element element)
throws NullPointerException
replace in interface Storeelement - Element to be cached
NullPointerException - if the Element is null or has a null key
|
ehcache | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||