Java Doc for CacheTC.java in  » Net » Terracotta » net » sf » ehcache » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » Terracotta » net.sf.ehcache 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   net.sf.ehcache.CacheTC

CacheTC
public class CacheTC implements Ehcache(Code)
This is a modification of the Ehcache net.sf.ehcache.Cache.java class, which is under the Apache open source license. In this implementation, DiskStore is not supported, and thus, most synchronized are removed since the memory store methods are being synchronized.


Field Summary
final public static  StringDEFAULT_CACHE_NAME
     A reserved word for cache names.
final public static  longDEFAULT_EXPIRY_THREAD_INTERVAL_SECONDS
     The default interval between runs of the expiry thread.
final public static  StringNET_SF_EHCACHE_DISABLED
     System Property based method of disabling ehcache.

Constructor Summary
public  CacheTC(String name, int maxElementsInMemory, boolean overflowToDisk, boolean eternal, long timeToLiveSeconds, long timeToIdleSeconds)
     1.0 Constructor.
public  CacheTC(String name, int maxElementsInMemory, boolean overflowToDisk, boolean eternal, long timeToLiveSeconds, long timeToIdleSeconds, boolean diskPersistent, long diskExpiryThreadIntervalSeconds)
     1.1 Constructor.
public  CacheTC(String name, int maxElementsInMemory, MemoryStoreEvictionPolicy memoryStoreEvictionPolicy, boolean overflowToDisk, String diskStorePath, boolean eternal, long timeToLiveSeconds, long timeToIdleSeconds, boolean diskPersistent, long diskExpiryThreadIntervalSeconds, RegisteredEventListeners registeredEventListeners)
     1.2 Constructor

The net.sf.ehcache.config.ConfigurationFactory and clients can create these.

public  CacheTC(String name, int maxElementsInMemory, MemoryStoreEvictionPolicy memoryStoreEvictionPolicy, boolean overflowToDisk, String diskStorePath, boolean eternal, long timeToLiveSeconds, long timeToIdleSeconds, boolean diskPersistent, long diskExpiryThreadIntervalSeconds, RegisteredEventListeners registeredEventListeners, BootstrapCacheLoader bootstrapCacheLoader)
     1.2.1 Constructor

The net.sf.ehcache.config.ConfigurationFactory and clients can create these.

public  CacheTC(String name, int maxElementsInMemory, MemoryStoreEvictionPolicy memoryStoreEvictionPolicy, boolean overflowToDisk, String diskStorePath, boolean eternal, long timeToLiveSeconds, long timeToIdleSeconds, boolean diskPersistent, long diskExpiryThreadIntervalSeconds, RegisteredEventListeners registeredEventListeners, BootstrapCacheLoader bootstrapCacheLoader, int maxElementsOnDisk)
     1.2.4 Constructor

The net.sf.ehcache.config.ConfigurationFactory and clients can create these.

public  CacheTC(String name, int maxElementsInMemory, MemoryStoreEvictionPolicy memoryStoreEvictionPolicy, boolean overflowToDisk, String diskStorePath, boolean eternal, long timeToLiveSeconds, long timeToIdleSeconds, boolean diskPersistent, long diskExpiryThreadIntervalSeconds, RegisteredEventListeners registeredEventListeners, BootstrapCacheLoader bootstrapCacheLoader, int maxElementsOnDisk, int diskSpoolBufferSizeMB)
    

Method Summary
public  voidbootstrap()
     Bootstrap command.
final public  longcalculateInMemorySize()
     Gets the size of the memory store for this cache.
public synchronized  voidclearStatistics()
     Resets statistics counters back to 0.
final public  Objectclone()
     Clones a cache.
public static  CacheTCconvert(Ehcache cache)
    
public  voiddispose()
     Flushes all cache items from memory to auxilliary caches and close the auxilliary caches.
public  booleanequals(Object object)
     An equals method which follows the contract of Object.equals(Object)
Parameters:
  object - the reference object with which to compare.
public  voidevictExpiredElements()
     Causes all elements stored in the Cache to be synchronously checked for expiry, and if expired, evicted.
final public  voidflush()
     Flushes all cache items from memory to the disk store, and from the DiskStore to disk.
final public  Elementget(Serializable key)
     Gets an element from the cache.
final public  Elementget(Object key)
     Gets an element from the cache.
public  BootstrapCacheLoadergetBootstrapCacheLoader()
     Accessor for the BootstrapCacheLoader associated with this cache.
public  CacheConfigurationgetCacheConfiguration()
    
final public  RegisteredEventListenersgetCacheEventNotificationService()
    
final public  CacheManagergetCacheManager()
     Gets the CacheManager managing this cache.
final public  longgetDiskExpiryThreadIntervalSeconds()
     the interval between runs of the expiry thread, where it checks the disk store for expired elements.
final public  intgetDiskStoreHitCount()
     Number of times a requested item was found in the Disk Store.
final public  intgetDiskStoreSize()
     Returns the number of elements in the disk store.
final public  StringgetGuid()
     The GUID for this cache instance can be used to determine whether two cache instance references are pointing to the same cache. the globally unique identifier for this cache instance.
final public  intgetHitCount()
     The number of times a requested item was found in the cache.
final public  ListgetKeys()
     Returns a list of all element keys in the cache, whether or not they are expired.
final public  ListgetKeysNoDuplicateCheck()
     Returns a list of all elements in the cache, whether or not they are expired.
final public  ListgetKeysWithExpiryCheck()
     Returns a list of all element keys in the cache.
final public  intgetMaxElementsInMemory()
     Gets the maximum number of elements to hold in memory.
public  intgetMaxElementsOnDisk()
    
final  MemoryStoregetMemoryStore()
     Gets the internal MemoryStore.
final public  MemoryStoreEvictionPolicygetMemoryStoreEvictionPolicy()
     The policy used to evict elements from the net.sf.ehcache.store.MemoryStore .
final public  intgetMemoryStoreHitCount()
     Number of times a requested item was found in the Memory Store.
final public  longgetMemoryStoreSize()
     Returns the number of elements in the memory store.
final public  intgetMissCountExpired()
     Number of times a requested element was found but was expired.
final public  intgetMissCountNotFound()
     Number of times a requested element was not found in the cache.
final public  StringgetName()
     Gets the cache name.
final public  ElementgetQuiet(Serializable key)
     Gets an element from the cache, without updating Element statistics.
final public  ElementgetQuiet(Object key)
     Gets an element from the cache, without updating Element statistics.
final public  intgetSize()
     Gets the size of the cache.
public  StatisticsgetStatistics()
    

Note, the CacheTC.getSize method will have the same value as the size reported by Statistics for the statistics accuracy of Statistics.STATISTICS_ACCURACY_BEST_EFFORT .

public  intgetStatisticsAccuracy()
     Accurately measuring statistics can be expensive.
final public  StatusgetStatus()
     Gets the status attribute of the Cache.
final public  longgetTimeToIdleSeconds()
     Gets timeToIdleSeconds.
final public  longgetTimeToLiveSeconds()
     Gets timeToLiveSeconds.
public  inthashCode()
     Returns a hash code value for the object.
public  voidinitialise()
     Newly created caches do not have a net.sf.ehcache.store.MemoryStore or a net.sf.ehcache.store.DiskStore .
final public  booleanisDiskPersistent()
    
final public  booleanisElementInMemory(Serializable key)
     Whether an Element is stored in the cache in Memory, indicating a very low cost of retrieval.
final public  booleanisElementInMemory(Object key)
     Whether an Element is stored in the cache in Memory, indicating a very low cost of retrieval.
final public  booleanisElementOnDisk(Serializable key)
     Whether an Element is stored in the cache on Disk, indicating a higher cost of retrieval.
final public  booleanisElementOnDisk(Object key)
     Whether an Element is stored in the cache on Disk, indicating a higher cost of retrieval.
final public  booleanisEternal()
     Are elements eternal.
final public  booleanisExpired(Element element)
     Checks whether this cache element has expired.
public  booleanisKeyInCache(Object key)
     An inexpensive check to see if the key exists in the cache.
final public  booleanisOverflowToDisk()
     Does the overflow go to disk.
public  booleanisValueInCache(Object value)
     An extremely expensive check to see if the value exists in the cache.
final public  voidput(Element element)
     Put an element in the cache.
final public  voidput(Element element, boolean doNotNotifyCacheReplicators)
     Put an element in the cache.
final public  voidputQuiet(Element element)
     Put an element in the cache, without updating statistics, or updating listeners.
final public  booleanremove(Serializable key)
     Removes an Element from the Cache.
final public  booleanremove(Object key)
     Removes an Element from the Cache.
final public  booleanremove(Serializable key, boolean doNotNotifyCacheReplicators)
     Removes an Element from the Cache.
final public  booleanremove(Object key, boolean doNotNotifyCacheReplicators)
     Removes an Element from the Cache.
public  voidremoveAll()
     Removes all cached items.
public  voidremoveAll(boolean doNotNotifyCacheReplicators)
     Removes all cached items.
final public  booleanremoveQuiet(Serializable key)
     Removes an Element from the Cache, without notifying listeners.
final public  booleanremoveQuiet(Object key)
     Removes an Element from the Cache, without notifying listeners.
public  voidsetBootstrapCacheLoader(BootstrapCacheLoader bootstrapCacheLoader)
     Sets the bootstrap cache loader.
public  voidsetCacheManager(CacheManager cacheManager)
     For use by CacheManager.
public  voidsetDiskStorePath(String diskStorePath)
     DiskStore paths can conflict between CacheManager instances.
final public  voidsetName(String name)
     Sets the cache name which will name.
Parameters:
  name - the name of the cache.
public  voidsetStatisticsAccuracy(int statisticsAccuracy)
     Sets the statistics accuracy.
final public  StringtoString()
     Returns a String representation of CacheTC .

Field Detail
DEFAULT_CACHE_NAME
final public static String DEFAULT_CACHE_NAME(Code)
A reserved word for cache names. It denotes a default configuration which is applied to caches created without configuration.



DEFAULT_EXPIRY_THREAD_INTERVAL_SECONDS
final public static long DEFAULT_EXPIRY_THREAD_INTERVAL_SECONDS(Code)
The default interval between runs of the expiry thread.



NET_SF_EHCACHE_DISABLED
final public static String NET_SF_EHCACHE_DISABLED(Code)
System Property based method of disabling ehcache. If disabled no elements will be added to a cache.

Set the property "net.sf.ehcache.disabled=true" to disable ehcache.

This can easily be done using java -Dnet.sf.ehcache.disabled=true in the command line.





Constructor Detail
CacheTC
public CacheTC(String name, int maxElementsInMemory, boolean overflowToDisk, boolean eternal, long timeToLiveSeconds, long timeToIdleSeconds)(Code)
1.0 Constructor.

The net.sf.ehcache.config.ConfigurationFactory and clients can create these.

A client can specify their own settings here and pass the CacheTC object into CacheManager.addCache to specify parameters other than the defaults.

Only the CacheManager can initialise them.

This constructor creates disk stores, if specified, that do not persist between restarts.

The default expiry thread interval of 120 seconds is used. This is the interval between runs of the expiry thread, where it checks the disk store for expired elements. It is not the the timeToLiveSeconds.
Parameters:
  name - the name of the cache
Parameters:
  maxElementsInMemory - the maximum number of elements in memory, before they are evicted
Parameters:
  overflowToDisk - whether to use the disk store; always false
Parameters:
  eternal - whether the elements in the cache are eternal, i.e. never expire; always false
Parameters:
  timeToLiveSeconds - the default amount of time to live for an element from its creation date
Parameters:
  timeToIdleSeconds - the default amount of time to live for an element from its last accessed or modified date
since:
   1.0




CacheTC
public CacheTC(String name, int maxElementsInMemory, boolean overflowToDisk, boolean eternal, long timeToLiveSeconds, long timeToIdleSeconds, boolean diskPersistent, long diskExpiryThreadIntervalSeconds)(Code)
1.1 Constructor.

The net.sf.ehcache.config.ConfigurationFactory and clients can create these.

A client can specify their own settings here and pass the CacheTC object into CacheManager.addCache to specify parameters other than the defaults.

Only the CacheManager can initialise them.
Parameters:
  name - the name of the cache
Parameters:
  maxElementsInMemory - the maximum number of elements in memory, before they are evicted
Parameters:
  overflowToDisk - whether to use the disk store; always false
Parameters:
  eternal - whether the elements in the cache are eternal, i.e. never expire; always false
Parameters:
  timeToLiveSeconds - the default amount of time to live for an element from its creation date
Parameters:
  timeToIdleSeconds - the default amount of time to live for an element from its last accessed or modified date
Parameters:
  diskPersistent - whether to persist the cache to disk between JVM restarts; always false
Parameters:
  diskExpiryThreadIntervalSeconds - how often to run the disk store expiry thread. A large number of 120 secondsplus is recommended
since:
   1.1




CacheTC
public CacheTC(String name, int maxElementsInMemory, MemoryStoreEvictionPolicy memoryStoreEvictionPolicy, boolean overflowToDisk, String diskStorePath, boolean eternal, long timeToLiveSeconds, long timeToIdleSeconds, boolean diskPersistent, long diskExpiryThreadIntervalSeconds, RegisteredEventListeners registeredEventListeners)(Code)
1.2 Constructor

The net.sf.ehcache.config.ConfigurationFactory and clients can create these.

A client can specify their own settings here and pass the CacheTC object into CacheManager.addCache to specify parameters other than the defaults.

Only the CacheManager can initialise them.
Parameters:
  name - the name of the cache
Parameters:
  maxElementsInMemory - the maximum number of elements in memory, before they are evicted
Parameters:
  memoryStoreEvictionPolicy - always uses DSO.
Parameters:
  overflowToDisk - whether to use the disk store; always false
Parameters:
  diskStorePath - this parameter is ignored. CacheManager sets it using setter injection.
Parameters:
  eternal - whether the elements in the cache are eternal, i.e. never expire; always false
Parameters:
  timeToLiveSeconds - the default amount of time to live for an element from its creation date
Parameters:
  timeToIdleSeconds - the default amount of time to live for an element from its last accessed or modified date
Parameters:
  diskPersistent - whether to persist the cache to disk between JVM restarts; always false
Parameters:
  diskExpiryThreadIntervalSeconds - how often to run the disk store expiry thread. A large number of 120 secondsplus is recommended
Parameters:
  registeredEventListeners - a notification service. Optionally null, in which case a new one with no registeredlisteners will be created.
since:
   1.2




CacheTC
public CacheTC(String name, int maxElementsInMemory, MemoryStoreEvictionPolicy memoryStoreEvictionPolicy, boolean overflowToDisk, String diskStorePath, boolean eternal, long timeToLiveSeconds, long timeToIdleSeconds, boolean diskPersistent, long diskExpiryThreadIntervalSeconds, RegisteredEventListeners registeredEventListeners, BootstrapCacheLoader bootstrapCacheLoader)(Code)
1.2.1 Constructor

The net.sf.ehcache.config.ConfigurationFactory and clients can create these.

A client can specify their own settings here and pass the CacheTC object into CacheManager.addCache to specify parameters other than the defaults.

Only the CacheManager can initialise them.
Parameters:
  name - the name of the cache
Parameters:
  maxElementsInMemory - the maximum number of elements in memory, before they are evicted
Parameters:
  memoryStoreEvictionPolicy - always uses DSO.
Parameters:
  overflowToDisk - whether to use the disk store; always false
Parameters:
  diskStorePath - this parameter is ignored. CacheManager sets it using setter injection.
Parameters:
  eternal - whether the elements in the cache are eternal, i.e. never expire; always false
Parameters:
  timeToLiveSeconds - the default amount of time to live for an element from its creation date
Parameters:
  timeToIdleSeconds - the default amount of time to live for an element from its last accessed or modified date
Parameters:
  diskPersistent - whether to persist the cache to disk between JVM restarts; always false
Parameters:
  diskExpiryThreadIntervalSeconds - how often to run the disk store expiry thread. A large number of 120 secondsplus is recommended
Parameters:
  registeredEventListeners - a notification service. Optionally null, in which case a new one with no registeredlisteners will be created.
Parameters:
  bootstrapCacheLoader - the BootstrapCacheLoader to use to populate the cache when it is first initialised.Null if none is required.
since:
   1.2.1




CacheTC
public CacheTC(String name, int maxElementsInMemory, MemoryStoreEvictionPolicy memoryStoreEvictionPolicy, boolean overflowToDisk, String diskStorePath, boolean eternal, long timeToLiveSeconds, long timeToIdleSeconds, boolean diskPersistent, long diskExpiryThreadIntervalSeconds, RegisteredEventListeners registeredEventListeners, BootstrapCacheLoader bootstrapCacheLoader, int maxElementsOnDisk)(Code)
1.2.4 Constructor

The net.sf.ehcache.config.ConfigurationFactory and clients can create these.

A client can specify their own settings here and pass the CacheTC object into CacheManager.addCache to specify parameters other than the defaults.

Only the CacheManager can initialise them.
Parameters:
  name - the name of the cache
Parameters:
  maxElementsInMemory - the maximum number of elements in memory, before they are evicted
Parameters:
  memoryStoreEvictionPolicy - always uses DSO.
Parameters:
  overflowToDisk - whether to use the disk store; always false
Parameters:
  diskStorePath - this parameter is ignored. CacheManager sets it using setter injection.
Parameters:
  eternal - whether the elements in the cache are eternal, i.e. never expire; always false
Parameters:
  timeToLiveSeconds - the default amount of time to live for an element from its creation date
Parameters:
  timeToIdleSeconds - the default amount of time to live for an element from its last accessed or modified date
Parameters:
  diskPersistent - whether to persist the cache to disk between JVM restarts; always false
Parameters:
  diskExpiryThreadIntervalSeconds - how often to run the disk store expiry thread. A large number of 120 secondsplus is recommended
Parameters:
  registeredEventListeners - a notification service. Optionally null, in which case a new one with no registeredlisteners will be created.
Parameters:
  bootstrapCacheLoader - the BootstrapCacheLoader to use to populate the cache when it is first initialised.Null if none is required.
since:
   1.2.4




CacheTC
public CacheTC(String name, int maxElementsInMemory, MemoryStoreEvictionPolicy memoryStoreEvictionPolicy, boolean overflowToDisk, String diskStorePath, boolean eternal, long timeToLiveSeconds, long timeToIdleSeconds, boolean diskPersistent, long diskExpiryThreadIntervalSeconds, RegisteredEventListeners registeredEventListeners, BootstrapCacheLoader bootstrapCacheLoader, int maxElementsOnDisk, int diskSpoolBufferSizeMB)(Code)




Method Detail
bootstrap
public void bootstrap()(Code)
Bootstrap command. This must be called after the Cache is intialised, during CacheManager initialisation. If loads are synchronous, they will complete before the CacheManager initialise completes, otherwise they will happen in the background.



calculateInMemorySize
final public long calculateInMemorySize() throws IllegalStateException, CacheException(Code)
Gets the size of the memory store for this cache. This method relies on calculating Serialized sizes. If the Element values are not Serializable they will show as zero.

Warning: This method can be very expensive to run. Allow approximately 1 second per 1MB of entries. Running this method could create liveness problems because the object lock is held for a long period

the approximate size of the memory store in bytes
throws:
  IllegalStateException -




clearStatistics
public synchronized void clearStatistics() throws IllegalStateException(Code)
Resets statistics counters back to 0.
throws:
  IllegalStateException - if the cache is not Status.STATUS_ALIVE



clone
final public Object clone() throws CloneNotSupportedException(Code)
Clones a cache. This is only legal if the cache has not been initialized. At that point only primitives have been set and no net.sf.ehcache.store.LruMemoryStore or net.sf.ehcache.store.DiskStore has been created.

A new, empty, RegisteredEventListeners is created on clone.

an object of type CacheTC
throws:
  CloneNotSupportedException -




convert
public static CacheTC convert(Ehcache cache)(Code)



dispose
public void dispose() throws IllegalStateException(Code)
Flushes all cache items from memory to auxilliary caches and close the auxilliary caches.

Should be invoked only by CacheManager.
throws:
  IllegalStateException - if the cache is not Status.STATUS_ALIVE




equals
public boolean equals(Object object)(Code)
An equals method which follows the contract of Object.equals(Object)
Parameters:
  object - the reference object with which to compare. true if this object is the same as the obj argument; false otherwise. Samefor a Cache means, the same GUID
See Also:   CacheTC.hashCode()
See Also:   java.util.Hashtable



evictExpiredElements
public void evictExpiredElements()(Code)
Causes all elements stored in the Cache to be synchronously checked for expiry, and if expired, evicted.



flush
final public void flush() throws IllegalStateException, CacheException(Code)
Flushes all cache items from memory to the disk store, and from the DiskStore to disk.
throws:
  IllegalStateException - if the cache is not Status.STATUS_ALIVE



get
final public Element get(Serializable key) throws IllegalStateException, CacheException(Code)
Gets an element from the cache. Updates Element Statistics

Note that the Element's lastAccessTime is always the time of this get. Use CacheTC.getQuiet(Object) to peak into the Element to see its last access time with get

Synchronization is handled within the method.
Parameters:
  key - a serializable value the element, or null, if it does not exist.
throws:
  IllegalStateException - if the cache is not Status.STATUS_ALIVE
See Also:   CacheTC.isExpired




get
final public Element get(Object key) throws IllegalStateException, CacheException(Code)
Gets an element from the cache. Updates Element Statistics

Note that the Element's lastAccessTime is always the time of this get. Use CacheTC.getQuiet(Object) to peak into the Element to see its last access time with get

Synchronization is handled within the method.
Parameters:
  key - an Object value the element, or null, if it does not exist.
throws:
  IllegalStateException - if the cache is not Status.STATUS_ALIVE
See Also:   CacheTC.isExpired
since:
   1.2




getBootstrapCacheLoader
public BootstrapCacheLoader getBootstrapCacheLoader()(Code)
Accessor for the BootstrapCacheLoader associated with this cache. For testing purposes.



getCacheConfiguration
public CacheConfiguration getCacheConfiguration()(Code)



getCacheEventNotificationService
final public RegisteredEventListeners getCacheEventNotificationService()(Code)
Use this to access the service in order to register and unregister listeners the RegisteredEventListeners instance for this cache.



getCacheManager
final public CacheManager getCacheManager()(Code)
Gets the CacheManager managing this cache. For a newly created cache this will be null until it has been added to a CacheManager. the manager or null if there is none



getDiskExpiryThreadIntervalSeconds
final public long getDiskExpiryThreadIntervalSeconds()(Code)
the interval between runs of the expiry thread, where it checks the disk store for expired elements. It isnot the the timeToLiveSeconds.



getDiskStoreHitCount
final public int getDiskStoreHitCount()(Code)
Number of times a requested item was found in the Disk Store.

The internal representation of this statistic has been changed to a long to cater for real world situations when an int is not sufficient to hold it. If the statistic is larger than Integer.MAX_VALUE a nonsensical value will be returned. Use net.sf.ehcache.Statistics which contains this statistic.

net.sf.ehcache.Statistics




getDiskStoreSize
final public int getDiskStoreSize() throws IllegalStateException(Code)
Returns the number of elements in the disk store. the number of elements in the disk store.
throws:
  IllegalStateException - if the cache is not Status.STATUS_ALIVE



getGuid
final public String getGuid()(Code)
The GUID for this cache instance can be used to determine whether two cache instance references are pointing to the same cache. the globally unique identifier for this cache instance. This is guaranteed to be unique.
since:
   1.2



getHitCount
final public int getHitCount()(Code)
The number of times a requested item was found in the cache.

The internal representation of this statistic has been changed to a long to cater for real world situations when an int is not sufficient to hold it. If the statistic is larger than Integer.MAX_VALUE a nonsensical value will be returned. Use net.sf.ehcache.Statistics which contains this statistic.

the number of times a requested item was found in the cachenet.sf.ehcache.Statistics




getKeys
final public List getKeys() throws IllegalStateException, CacheException(Code)
Returns a list of all element keys in the cache, whether or not they are expired.

The returned keys are unique and can be considered a set.

The List returned is not live. It is a copy.

The time taken is O(n). On a single cpu 1.8Ghz P4, approximately 8ms is required for each 1000 entries. a list of Object keys
throws:
  IllegalStateException - if the cache is not Status.STATUS_ALIVE




getKeysNoDuplicateCheck
final public List getKeysNoDuplicateCheck() throws IllegalStateException(Code)
Returns a list of all elements in the cache, whether or not they are expired.

The returned keys are not unique and may contain duplicates. If the cache is only using the memory store, the list will be unique. If the disk store is being used as well, it will likely contain duplicates, because of the internal store design.

The List returned is not live. It is a copy.

The time taken is O(log n). On a single cpu 1.8Ghz P4, approximately 6ms is required for 1000 entries and 36 for 50000.

This is the fastest getKeys method a list of Object keys
throws:
  IllegalStateException - if the cache is not Status.STATUS_ALIVE




getKeysWithExpiryCheck
final public List getKeysWithExpiryCheck() throws IllegalStateException, CacheException(Code)
Returns a list of all element keys in the cache. Only keys of non-expired elements are returned.

The returned keys are unique and can be considered a set.

The List returned is not live. It is a copy.

The time taken is O(n), where n is the number of elements in the cache. On a 1.8Ghz P4, the time taken is approximately 200ms per 1000 entries. This method is not syncrhonized, because it relies on a non-live list returned from CacheTC.getKeys() , which is synchronised, and which takes 8ms per 1000 entries. This way cache liveness is preserved, even if this method is very slow to return.

Consider whether your usage requires checking for expired keys. Because this method takes so long, depending on cache settings, the list could be quite out of date by the time you get it. a list of Object keys
throws:
  IllegalStateException - if the cache is not Status.STATUS_ALIVE




getMaxElementsInMemory
final public int getMaxElementsInMemory()(Code)
Gets the maximum number of elements to hold in memory.



getMaxElementsOnDisk
public int getMaxElementsOnDisk()(Code)
Gets the maximum number of elements to hold on Disk



getMemoryStore
final MemoryStore getMemoryStore() throws IllegalStateException(Code)
Gets the internal MemoryStore. the MemoryStore referenced by this cache
throws:
  IllegalStateException - if the cache is not Status.STATUS_ALIVE



getMemoryStoreEvictionPolicy
final public MemoryStoreEvictionPolicy getMemoryStoreEvictionPolicy()(Code)
The policy used to evict elements from the net.sf.ehcache.store.MemoryStore . This can be one of:
  1. LRU - least recently used
  2. LFU - least frequently used
  3. FIFO - first in first out, the oldest element by creation time
The default value is LRU
since:
   1.2



getMemoryStoreHitCount
final public int getMemoryStoreHitCount()(Code)
Number of times a requested item was found in the Memory Store.

The internal representation of this statistic has been changed to a long to cater for real world situations when an int is not sufficient to hold it. If the statistic is larger than Integer.MAX_VALUE a nonsensical value will be returned. Use net.sf.ehcache.Statistics which contains this statistic.

Number of times a requested item was found in the Memory Store.net.sf.ehcache.Statistics




getMemoryStoreSize
final public long getMemoryStoreSize() throws IllegalStateException(Code)
Returns the number of elements in the memory store. the number of elements in the memory store
throws:
  IllegalStateException - if the cache is not Status.STATUS_ALIVE



getMissCountExpired
final public int getMissCountExpired()(Code)
Number of times a requested element was found but was expired.

The internal representation of this statistic has been changed to a long to cater for real world situations when an int is not sufficient to hold it. If the statistic is larger than Integer.MAX_VALUE a nonsensical value will be returned. Use net.sf.ehcache.Statistics which contains this statistic.

net.sf.ehcache.Statistics




getMissCountNotFound
final public int getMissCountNotFound()(Code)
Number of times a requested element was not found in the cache. This may be because it expired, in which case this will also be recorded in CacheTC.getMissCountExpired , or because it was simply not there.

The internal representation of this statistic has been changed to a long to cater for real world situations when an int is not sufficient to hold it. If the statistic is larger than Integer.MAX_VALUE a nonsensical value will be returned. Use net.sf.ehcache.Statistics which contains this statistic.

net.sf.ehcache.Statistics




getName
final public String getName()(Code)
Gets the cache name.



getQuiet
final public Element getQuiet(Serializable key) throws IllegalStateException, CacheException(Code)
Gets an element from the cache, without updating Element statistics. Cache statistics are still updated.

Synchronization is handled within the method.
Parameters:
  key - a serializable value the element, or null, if it does not exist.
throws:
  IllegalStateException - if the cache is not Status.STATUS_ALIVE
See Also:   CacheTC.isExpired




getQuiet
final public Element getQuiet(Object key) throws IllegalStateException, CacheException(Code)
Gets an element from the cache, without updating Element statistics. Cache statistics are not updated.

Synchronization is handled within the method.
Parameters:
  key - a serializable value the element, or null, if it does not exist.
throws:
  IllegalStateException - if the cache is not Status.STATUS_ALIVE
See Also:   CacheTC.isExpired
since:
   1.2




getSize
final public int getSize() throws IllegalStateException, CacheException(Code)
Gets the size of the cache. This is a subtle concept. See below.

The size is the number of Element s in the MemoryStore plus the number of Element s in the DiskStore .

This number is the actual number of elements, including expired elements that have not been removed.

Expired elements are removed from the the memory store when getting an expired element, or when attempting to spool an expired element to disk.

Expired elements are removed from the disk store when getting an expired element, or when the expiry thread runs, which is once every five minutes.

To get an exact size, which would exclude expired elements, use CacheTC.getKeysWithExpiryCheck() .size(), although see that method for the approximate time that would take.

To get a very fast result, use CacheTC.getKeysNoDuplicateCheck() .size(). If the disk store is being used, there will be some duplicates. The size value
throws:
  IllegalStateException - if the cache is not Status.STATUS_ALIVE




getStatistics
public Statistics getStatistics() throws IllegalStateException(Code)

Note, the CacheTC.getSize method will have the same value as the size reported by Statistics for the statistics accuracy of Statistics.STATISTICS_ACCURACY_BEST_EFFORT .




getStatisticsAccuracy
public int getStatisticsAccuracy()(Code)
Accurately measuring statistics can be expensive. Returns the current accuracy setting. one of Statistics.STATISTICS_ACCURACY_BEST_EFFORT,Statistics.STATISTICS_ACCURACY_GUARANTEED, Statistics.STATISTICS_ACCURACY_NONE



getStatus
final public Status getStatus()(Code)
Gets the status attribute of the Cache. The status value from the Status enum class



getTimeToIdleSeconds
final public long getTimeToIdleSeconds()(Code)
Gets timeToIdleSeconds.



getTimeToLiveSeconds
final public long getTimeToLiveSeconds()(Code)
Gets timeToLiveSeconds.



hashCode
public int hashCode()(Code)
Returns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the Object.equals(Object) method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hashtables.

As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.)

This implementation use the GUID of the cache. a hash code value for this object.
See Also:   Object.equals(Object)
See Also:   java.util.Hashtable




initialise
public void initialise()(Code)
Newly created caches do not have a net.sf.ehcache.store.MemoryStore or a net.sf.ehcache.store.DiskStore .

This method creates those and makes the cache ready to accept elements




isDiskPersistent
final public boolean isDiskPersistent()(Code)
true if the cache overflows to disk and the disk is persistent between restarts



isElementInMemory
final public boolean isElementInMemory(Serializable key)(Code)
Whether an Element is stored in the cache in Memory, indicating a very low cost of retrieval. true if an element matching the key is found in memory



isElementInMemory
final public boolean isElementInMemory(Object key)(Code)
Whether an Element is stored in the cache in Memory, indicating a very low cost of retrieval. true if an element matching the key is found in memory
since:
   1.2



isElementOnDisk
final public boolean isElementOnDisk(Serializable key)(Code)
Whether an Element is stored in the cache on Disk, indicating a higher cost of retrieval. true if an element matching the key is found in the diskStore



isElementOnDisk
final public boolean isElementOnDisk(Object key)(Code)
Whether an Element is stored in the cache on Disk, indicating a higher cost of retrieval. true if an element matching the key is found in the diskStore
since:
   1.2



isEternal
final public boolean isEternal()(Code)
Are elements eternal.



isExpired
final public boolean isExpired(Element element) throws IllegalStateException, NullPointerException(Code)
Checks whether this cache element has expired.

The element is expired if:

  1. the idle time is non-zero and has elapsed, unless the cache is eternal; or
  2. the time to live is non-zero and has elapsed, unless the cache is eternal; or
  3. the value of the element is null.
true if it has expired
throws:
  IllegalStateException - if the cache is not Status.STATUS_ALIVE
throws:
  NullPointerException - if the element is null



isKeyInCache
public boolean isKeyInCache(Object key)(Code)
An inexpensive check to see if the key exists in the cache.

This method is not synchronized. It is possible that an element may exist in the cache aned be removed before the check gets to it, or vice versa.
Parameters:
  key - the key to check. true if an Element matching the key is found in the cache. No assertions are made about the state of theElement.




isOverflowToDisk
final public boolean isOverflowToDisk()(Code)
Does the overflow go to disk.



isValueInCache
public boolean isValueInCache(Object value)(Code)
An extremely expensive check to see if the value exists in the cache. This implementation is O(n). Ehcache is not designed for efficient access in this manner.

This method is not synchronized. It is possible that an element may exist in the cache aned be removed before the check gets to it, or vice versa. Because it is slow to execute the probability of that this will have happened.
Parameters:
  value - to check for true if an Element matching the key is found in the cache. No assertions are made about the state of theElement.




put
final public void put(Element element) throws IllegalArgumentException, IllegalStateException, CacheException(Code)
Put an element in the cache.

Resets the access statistics on the element, which would be the case if it has previously been gotten from a cache, and is now being put back.

Also notifies the CacheEventListener that:

  • the element was put, but only if the Element was actually put.
  • if the element exists in the cache, that an update has occurred, even if the element would be expired if it was requested
Synchronization is handled within the method.
Parameters:
  element - An object. If Serializable it can fully participate in replication and the DiskStore.
throws:
  IllegalStateException - if the cache is not Status.STATUS_ALIVE
throws:
  IllegalArgumentException - if the element is null



put
final public void put(Element element, boolean doNotNotifyCacheReplicators) throws IllegalArgumentException, IllegalStateException, CacheException(Code)
Put an element in the cache.

Resets the access statistics on the element, which would be the case if it has previously been gotten from a cache, and is now being put back.

Also notifies the CacheEventListener that:

  • the element was put, but only if the Element was actually put.
  • if the element exists in the cache, that an update has occurred, even if the element would be expired if it was requested
Synchronization is handled within the method.
Parameters:
  element - An object. If Serializable it can fully participate in replication and the DiskStore.
Parameters:
  doNotNotifyCacheReplicators - whether the put is coming from a doNotNotifyCacheReplicators cache peer, inwhich case this put should not initiate a further notification to doNotNotifyCacheReplicators cache peers
throws:
  IllegalStateException - if the cache is not Status.STATUS_ALIVE
throws:
  IllegalArgumentException - if the element is null



putQuiet
final public void putQuiet(Element element) throws IllegalArgumentException, IllegalStateException, CacheException(Code)
Put an element in the cache, without updating statistics, or updating listeners. This is meant to be used in conjunction with CacheTC.getQuiet . Synchronization is handled within the method.
Parameters:
  element - An object. If Serializable it can fully participate in replication and the DiskStore.
throws:
  IllegalStateException - if the cache is not Status.STATUS_ALIVE
throws:
  IllegalArgumentException - if the element is null



remove
final public boolean remove(Serializable key) throws IllegalStateException(Code)
Removes an Element from the Cache. This also removes it from any stores it may be in.

Also notifies the CacheEventListener after the element was removed, but only if an Element with the key actually existed.

Synchronization is handled within the method.
Parameters:
  key - the element key to operate on true if the element was removed, false if it was not found in the cache
throws:
  IllegalStateException - if the cache is not Status.STATUS_ALIVE




remove
final public boolean remove(Object key) throws IllegalStateException(Code)
Removes an Element from the Cache. This also removes it from any stores it may be in.

Also notifies the CacheEventListener after the element was removed, but only if an Element with the key actually existed.

Synchronization is handled within the method.
Parameters:
  key - the element key to operate on true if the element was removed, false if it was not found in the cache
throws:
  IllegalStateException - if the cache is not Status.STATUS_ALIVE
since:
   1.2




remove
final public boolean remove(Serializable key, boolean doNotNotifyCacheReplicators) throws IllegalStateException(Code)
Removes an Element from the Cache. This also removes it from any stores it may be in.

Also notifies the CacheEventListener after the element was removed, but only if an Element with the key actually existed.

Synchronization is handled within the method.
Parameters:
  key - the element key to operate on
Parameters:
  doNotNotifyCacheReplicators - whether the put is coming from a doNotNotifyCacheReplicators cache peer, inwhich case this put should not initiate a further notification to doNotNotifyCacheReplicators cache peers true if the element was removed, false if it was not found in the cache
throws:
  IllegalStateException - if the cache is not Status.STATUS_ALIVE




remove
final public boolean remove(Object key, boolean doNotNotifyCacheReplicators) throws IllegalStateException(Code)
Removes an Element from the Cache. This also removes it from any stores it may be in.

Also notifies the CacheEventListener after the element was removed, but only if an Element with the key actually existed.

Synchronization is handled within the method.
Parameters:
  key - the element key to operate on
Parameters:
  doNotNotifyCacheReplicators - whether the put is coming from a doNotNotifyCacheReplicators cache peer, inwhich case this put should not initiate a further notification to doNotNotifyCacheReplicators cache peers true if the element was removed, false if it was not found in the cache
throws:
  IllegalStateException - if the cache is not Status.STATUS_ALIVE




removeAll
public void removeAll() throws IllegalStateException, CacheException(Code)
Removes all cached items. Synchronization is handled within the method.
throws:
  IllegalStateException - if the cache is not Status.STATUS_ALIVE



removeAll
public void removeAll(boolean doNotNotifyCacheReplicators) throws IllegalStateException, CacheException(Code)
Removes all cached items. Synchronization is handled within the method.
throws:
  IllegalStateException - if the cache is not Status.STATUS_ALIVE



removeQuiet
final public boolean removeQuiet(Serializable key) throws IllegalStateException(Code)
Removes an Element from the Cache, without notifying listeners. This also removes it from any stores it may be in.

Synchronization is handled within the method.
Parameters:
  key - the element key to operate on true if the element was removed, false if it was not found in the cache
throws:
  IllegalStateException - if the cache is not Status.STATUS_ALIVE




removeQuiet
final public boolean removeQuiet(Object key) throws IllegalStateException(Code)
Removes an Element from the Cache, without notifying listeners. This also removes it from any stores it may be in.

Synchronization is handled within the method.
Parameters:
  key - the element key to operate on true if the element was removed, false if it was not found in the cache
throws:
  IllegalStateException - if the cache is not Status.STATUS_ALIVE
since:
   1.2




setBootstrapCacheLoader
public void setBootstrapCacheLoader(BootstrapCacheLoader bootstrapCacheLoader) throws CacheException(Code)
Sets the bootstrap cache loader.
Parameters:
  bootstrapCacheLoader - the loader to be used
throws:
  CacheException - if this method is called after the cache is initialized



setCacheManager
public void setCacheManager(CacheManager cacheManager)(Code)
For use by CacheManager.
Parameters:
  cacheManager - the CacheManager for this cache to use.



setDiskStorePath
public void setDiskStorePath(String diskStorePath) throws CacheException(Code)
DiskStore paths can conflict between CacheManager instances. This method allows the path to be changed.
Parameters:
  diskStorePath - the new path to be used.
throws:
  CacheException - if this method is called after the cache is initialized



setName
final public void setName(String name) throws IllegalArgumentException(Code)
Sets the cache name which will name.
Parameters:
  name - the name of the cache. Should not be null. Should also not contain any '/' characters, as theseinterfere with distribution
throws:
  IllegalArgumentException - if an illegal name is used.



setStatisticsAccuracy
public void setStatisticsAccuracy(int statisticsAccuracy)(Code)
Sets the statistics accuracy.
Parameters:
  statisticsAccuracy - one of Statistics.STATISTICS_ACCURACY_BEST_EFFORT,Statistics.STATISTICS_ACCURACY_GUARANTEED, Statistics.STATISTICS_ACCURACY_NONE



toString
final public String toString()(Code)
Returns a String representation of CacheTC .



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.