Java Doc for LRUCache.java in  » Database-ORM » XORM » org » xorm » cache » 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 » Database ORM » XORM » org.xorm.cache 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.xorm.cache.LRUCache

LRUCache
public class LRUCache implements DataCache(Code)
An LRU Cache with a hard and soft reference limit. Objects that exceed the hard limit are stored as soft references, and objects that exceed the soft limit are discarded from the cache. The hard limit and soft limit are additive, in that hard limit is the number of objects to store with hard references, and the soft limit is the number of objects to store with soft references, exclusive of the hard limit. Hence, a hard limit of 10, and soft limit of 20 would create a (possible) cache size of 30. Since items stored as soft references are subject to collection by the Garbage collector, the soft reference cache will often be smaller than the limit set on it. It is possible to also configure the cache to behave as only a soft or hard cache by simply configuring the hard and soft limit appropriately. See the additional documentation below about how to configure this. This class uses a referenceQueue to insure that values removed from the This class can also be configured to log its statistics to its logger (defined as Logger.getLogger("org.xorm.cache.LRUCache")) Normally, this class would be used by adding the following properties to the properties files given to xorm at startup:
  • org.xorm.cache.DataCacheClass=org.xorm.cache.LRUCache
The following properties will override the default values in this class:
  • org.xorm.cache.LRUCache.hardSize=<non-negative intValue>
  • org.xorm.cache.LRUCache.softSize=<intValue>
  • org.xorm.cache.LRUCache.logInterval=<intValue>
See setProperties for a description of the meaning of these properties.
author:
   Harry Evans

Inner Class :static class LRUMap extends java.util.LinkedHashMap

Field Summary
final public static  intDEFAULT_HARD_SIZE
    
final public static  longDEFAULT_LOG_INTERVAL
    
final public static  intDEFAULT_SOFT_SIZE
    

Constructor Summary
public  LRUCache(int hardSize, int softSize, long aLogInterval)
     Construct a LRUCache.
public  LRUCache()
     Construct an LRUCache using DEFAULT_HARD_SIZE, DEFAULT_SOFT_SIZE, and DEFAULT_LOG_INTERVAL.

Method Summary
public  voidadd(Row row)
    
public  voidaddAll(Collection c)
     Optional method to add a collection of objects to the cache all at once. Not currently used by xorm or defined by the xorm interface.
Parameters:
  c - A Collection of rows to be added to the cache.
public  Rowget(Table table, Object aPrimaryKey)
     Retrieves a cloned copy of the Row from the cache with the matching primary key.
public  voidlog()
     Optional method for use by external classes to force logging of the cache usage statistics regardless of the value of logInterval.
public  voidremove(Row row)
    
public  ObjectremoveValue(Object value)
     Optional method to remove a value from the cache.
public  voidsetFactory(InterfaceManagerFactory factory)
    
public  voidsetProperties(Properties props)
     This method is called by XORM after reflectively instantiating the class.

Field Detail
DEFAULT_HARD_SIZE
final public static int DEFAULT_HARD_SIZE(Code)



DEFAULT_LOG_INTERVAL
final public static long DEFAULT_LOG_INTERVAL(Code)



DEFAULT_SOFT_SIZE
final public static int DEFAULT_SOFT_SIZE(Code)




Constructor Detail
LRUCache
public LRUCache(int hardSize, int softSize, long aLogInterval)(Code)
Construct a LRUCache. This method is provided primarily for use when programatically assigning the cache that XORM will use. The default constructor is usually the one that gets used.
Parameters:
  hardSize - The number of objects to keep hard references to. Ifthis number is greater than 0, keep references to that number of objectswith hard references. Objects that are discarded from the hard cachewill be put into soft cache, if soft cache does not have a size of 0.If this value is 0, do not create a hard cache. An exception is thrownif this value is less than 0.
Parameters:
  softSize - The number of objects to keep soft references to. Ifthis number is greater than 0, keep references to that number of objectswith soft references. Objects that are discarded from the soft cache,either through lack of space, or through garbage collection, arediscarded completely from the cache. If this value is 0, do not create asoft cache. If this value is less than 0, the number of referencesstored will be limited to the amount of memory in the system, and howaggressive the garbage collector is.
Parameters:
  aLogInterval - the amount of time in milliseconds to log usagestatistics to the logger ("org.xorm.cache.LRUCache"). If this value is0, always log. If this value is a negative number, never log. If thisvalue is positive, log whenever that number of milliseconds has elapsedand the cache is accessed. Logging is done on a best effort basis, anddoes not use a background thread. Therefore, if the cache is notaccessed for time greater than the log interval, no values will belogged.
throws:
  RuntimeException - if the hardSize is less than 0, or thehardSize and softSize are both 0



LRUCache
public LRUCache()(Code)
Construct an LRUCache using DEFAULT_HARD_SIZE, DEFAULT_SOFT_SIZE, and DEFAULT_LOG_INTERVAL. This constructor is provided to enable reflective instantiation of the cache. It is normally used in combination with a call to setProperties, which will result in the cache extracting (possibly) different values than the default with which to run.




Method Detail
add
public void add(Row row)(Code)



addAll
public void addAll(Collection c)(Code)
Optional method to add a collection of objects to the cache all at once. Not currently used by xorm or defined by the xorm interface.
Parameters:
  c - A Collection of rows to be added to the cache. The Rows will beadded in Iterator order.



get
public Row get(Table table, Object aPrimaryKey)(Code)
Retrieves a cloned copy of the Row from the cache with the matching primary key.



log
public void log()(Code)
Optional method for use by external classes to force logging of the cache usage statistics regardless of the value of logInterval.



remove
public void remove(Row row)(Code)



removeValue
public Object removeValue(Object value)(Code)
Optional method to remove a value from the cache. Since all objects removed are Rows, this method should not be called directly in the near future.



setFactory
public void setFactory(InterfaceManagerFactory factory)(Code)



setProperties
public void setProperties(Properties props)(Code)
This method is called by XORM after reflectively instantiating the class. This method looks for the following properties:
  • org.xorm.cache.LRUCache.hardSize
  • org.xorm.cache.LRUCache.softSize
  • org.xorm.cache.LRUCache.logInterval
Any property that isn't found will have the class default value assigned to it.
Parameters:
  props - The Properties object (possibly) containing values to usefor hardSize, softSize, and logInterval.



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.