Java Doc for UtilCache.java in  » ERP-CRM-Financial » SourceTap-CRM » org » ofbiz » base » util » 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 » ERP CRM Financial » SourceTap CRM » org.ofbiz.base.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.ofbiz.base.util.UtilCache

All known Subclasses:   com.sourcetap.sfa.ui.UICache,
UtilCache
public class UtilCache (Code)
Generalized caching utility. Provides a number of caching features:
  • Limited or unlimited element capacity
  • If limited, removes elements with the LRU (Least Recently Used) algorithm
  • Keeps track of when each element was loaded into the cache
  • Using the expireTime can report whether a given element has expired
  • Counts misses and hits

author:
   David E. Jones
version:
   $Revision: 1.2 $
since:
   2.0

Inner Class :public static class CacheLine

Field Summary
public  MapcacheLineTable
     A hashtable containing a CacheLine object with a value and a loadTime for each element.
protected static  MapdefaultIndices
     An index number appended to utilCacheTable names when there are conflicts.
protected  longexpireTime
     Specifies the amount of time since initial loading before an element will be reported as expired.
protected  longhitCount
    
public  LinkedListkeyLRUList
    
protected  longmaxSize
     The maximum number of elements in the cache.
protected  longmissCount
    
protected  Stringname
     The name of the UtilCache instance, is also the key for the instance in utilCacheTable.
protected  booleanuseSoftReference
    
public static  MaputilCacheTable
     A static Map to keep track of all of the UtilCache instances.

Constructor Summary
public  UtilCache(String cacheName, long maxSize, long expireTime, boolean useSoftReference)
     Constructor which specifies the cacheName as well as the maxSize, expireTime and useSoftReference.
public  UtilCache(String cacheName, long maxSize, long expireTime)
     Constructor which specifies the cacheName as well as the maxSize and expireTime.
public  UtilCache(long maxSize, long expireTime)
     Constructor which specifies the maxSize and expireTime.
public  UtilCache(String cacheName)
     This constructor takes a name for the cache, puts itself in the utilCacheTable.
public  UtilCache()
     Default constructor, all members stay at default values as defined in cache.properties, or the defaults in this file if cache.properties is not found, or there are no 'default' entries in it.

Method Summary
public synchronized  voidclear()
    
public static  voidclearAllCaches()
    
public  voidclearCounters()
    
public  voidclearExpired()
    
public static  voidclearExpiredFromAllCaches()
    
public  booleancontainsKey(Object key)
     Returns a boolean specifying whether or not an element with the specified key is in the cache.
public  Objectget(Object key)
     Gets an element from the cache according to the specified key.
public  longgetExpireTime()
    
public  longgetHitCount()
    
public  longgetMaxSize()
    
public  longgetMissCount()
    
public  StringgetName()
     Getter for the name of the UtilCache instance.
protected  StringgetNextDefaultIndex(String cacheName)
    
public  booleangetUseSoftReference()
    
public  booleanhasExpired(Object key)
     Returns a boolean specifying whether or not the element corresponding to the key has expired. Only returns true if element is in cache and has expired.
protected  booleanhasExpired(UtilCache.CacheLine line)
    
public synchronized  voidput(Object key, Object value)
    
public synchronized  Objectremove(Object key)
    
public  voidsetExpireTime(long expireTime)
     Sets the expire time for the cache elements.
public  voidsetMaxSize(long maxSize)
     Sets the maximum number of elements in the cache.
protected  voidsetPropertiesParams(String cacheName)
    
public  voidsetUseSoftReference(boolean useSoftReference)
    
public  longsize()
    
public static  booleanvalidKey(String cacheName, Object key)
    

Field Detail
cacheLineTable
public Map cacheLineTable(Code)
A hashtable containing a CacheLine object with a value and a loadTime for each element.



defaultIndices
protected static Map defaultIndices(Code)
An index number appended to utilCacheTable names when there are conflicts.



expireTime
protected long expireTime(Code)
Specifies the amount of time since initial loading before an element will be reported as expired. If set to 0, elements will never expire.



hitCount
protected long hitCount(Code)
A count of the number of cache hits



keyLRUList
public LinkedList keyLRUList(Code)
A list of the elements order by Least Recent Use



maxSize
protected long maxSize(Code)
The maximum number of elements in the cache. If set to 0, there will be no limit on the number of elements in the cache.



missCount
protected long missCount(Code)
A count of the number of cache misses



name
protected String name(Code)
The name of the UtilCache instance, is also the key for the instance in utilCacheTable.



useSoftReference
protected boolean useSoftReference(Code)
Specifies whether or not to use soft references for this cache, defaults to false



utilCacheTable
public static Map utilCacheTable(Code)
A static Map to keep track of all of the UtilCache instances.




Constructor Detail
UtilCache
public UtilCache(String cacheName, long maxSize, long expireTime, boolean useSoftReference)(Code)
Constructor which specifies the cacheName as well as the maxSize, expireTime and useSoftReference. The passed maxSize, expireTime and useSoftReference will be overridden by values from cache.properties if found.
Parameters:
  maxSize - The maxSize member is set to this value
Parameters:
  expireTime - The expireTime member is set to this value
Parameters:
  cacheName - The name of the cache.
Parameters:
  useSoftReference - Specifies whether or not to use soft references for this cache.



UtilCache
public UtilCache(String cacheName, long maxSize, long expireTime)(Code)
Constructor which specifies the cacheName as well as the maxSize and expireTime. The passed maxSize and expireTime will be overridden by values from cache.properties if found.
Parameters:
  maxSize - The maxSize member is set to this value
Parameters:
  expireTime - The expireTime member is set to this value
Parameters:
  cacheName - The name of the cache.



UtilCache
public UtilCache(long maxSize, long expireTime)(Code)
Constructor which specifies the maxSize and expireTime.
Parameters:
  maxSize - The maxSize member is set to this value
Parameters:
  expireTime - The expireTime member is set to this value



UtilCache
public UtilCache(String cacheName)(Code)
This constructor takes a name for the cache, puts itself in the utilCacheTable. It also uses the cacheName to lookup the initialization parameters from cache.properties.
Parameters:
  cacheName - The name of the cache.



UtilCache
public UtilCache()(Code)
Default constructor, all members stay at default values as defined in cache.properties, or the defaults in this file if cache.properties is not found, or there are no 'default' entries in it.




Method Detail
clear
public synchronized void clear()(Code)
Removes all elements from this cache



clearAllCaches
public static void clearAllCaches()(Code)
Removes all elements from this cache



clearCounters
public void clearCounters()(Code)
Clears the hit and miss counters



clearExpired
public void clearExpired()(Code)
Clears all expired cache entries; also clear any cache entries where the SoftReference in the CacheLine object has been cleared by the gc



clearExpiredFromAllCaches
public static void clearExpiredFromAllCaches()(Code)
Clears all expired cache entries from all caches



containsKey
public boolean containsKey(Object key)(Code)
Returns a boolean specifying whether or not an element with the specified key is in the cache. If the requested element hasExpired, it is removed before it is looked up which causes the function to return false.
Parameters:
  key - The key for the element, used to reference it in the hastables and LRU linked list True is the cache contains an element corresponding to the specified key, otherwise false



get
public Object get(Object key)(Code)
Gets an element from the cache according to the specified key. If the requested element hasExpired, it is removed before it is looked up which causes the function to return null.
Parameters:
  key - The key for the element, used to reference it in the hastables and LRU linked list The value of the element specified by the key



getExpireTime
public long getExpireTime()(Code)
return the current expire time for the cache elements The expire time for the cache elements



getHitCount
public long getHitCount()(Code)
Returns the number of successful hits on the cache The number of successful cache hits



getMaxSize
public long getMaxSize()(Code)
Returns the current maximum number of elements in the cache The maximum number of elements in the cache



getMissCount
public long getMissCount()(Code)
Returns the number of cache misses The number of cache misses



getName
public String getName()(Code)
Getter for the name of the UtilCache instance. The name of the instance



getNextDefaultIndex
protected String getNextDefaultIndex(String cacheName)(Code)



getUseSoftReference
public boolean getUseSoftReference()(Code)
Return whether or not the cache lines should use a soft reference to the data



hasExpired
public boolean hasExpired(Object key)(Code)
Returns a boolean specifying whether or not the element corresponding to the key has expired. Only returns true if element is in cache and has expired. Error conditions return false, if no expireTable entry, returns true. Always returns false if expireTime <= 0. Also, if SoftReference in the CacheLine object has been cleared by the gc return true.
Parameters:
  key - The key for the element, used to reference it in the hastables and LRU linked list True is the element corresponding to the specified key has expired, otherwise false



hasExpired
protected boolean hasExpired(UtilCache.CacheLine line)(Code)



put
public synchronized void put(Object key, Object value)(Code)
Puts or loads the passed element into the cache
Parameters:
  key - The key for the element, used to reference it in the hastables and LRU linked list
Parameters:
  value - The value of the element



remove
public synchronized Object remove(Object key)(Code)
Removes an element from the cache according to the specified key
Parameters:
  key - The key for the element, used to reference it in the hastables and LRU linked list The value of the removed element specified by the key



setExpireTime
public void setExpireTime(long expireTime)(Code)
Sets the expire time for the cache elements. If 0, elements never expire.
Parameters:
  expireTime - The expire time for the cache elements



setMaxSize
public void setMaxSize(long maxSize)(Code)
Sets the maximum number of elements in the cache. If 0, there is no maximum.
Parameters:
  maxSize - The maximum number of elements in the cache



setPropertiesParams
protected void setPropertiesParams(String cacheName)(Code)



setUseSoftReference
public void setUseSoftReference(boolean useSoftReference)(Code)
Set whether or not the cache lines should use a soft reference to the data



size
public long size()(Code)
Returns the number of elements currently in the cache The number of elements currently in the cache



validKey
public static boolean validKey(String cacheName, Object key)(Code)
Checks for a non-expired key in a specific cache



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.