J2EE objectcaching frameworks

一、Object Caching 的优点:
    * Significant improvement in application performance.
    * Scalability is another benefit of object caching.

 

二、Object Caching 的缺点:
    * Need big memory size.
    * Synchronization complexity.

 

三、什么样的数据需要缓存:
     Basically, any data that does not frequently change and requires asignificant amount of time to return from the data source is a goodcandidate for caching.

 

四、什么样的数据不适合缓存:
     *Secure information that other users can access on a Website.

    * Personal information, such as Social Security Number and creditcard details.
    * Business information that changes frequently and causes problemsif not up-to-date and accurate.
    * Session-specific data that may not be intended for access byother users.

 

五、HttpSession作为缓存时实现的原理:
    The HttpSession object in the Tomcat servlet container offers agood example of object caching. Tomcat uses an instance ofHashtable to store session objects and expire stale session objectsusing a background thread.

 

六、缓存中数据删除的时机:
    * Associating a "time-to-live" (TTL) or "idle-time" with anobject.
    * When the caching system's capacity has beenreached (this is a configurable value).
    * Objects not recently used.

 

七、缓存实现的算法:
   These algorithms are based on criteria such as least frequentlyused (LFU), least recently used (LRU), most recently used (MRU),first in first out (FIFO), last access time, and object size. Eachalgorithm has advantages and disadvantages. LFU and LRU are simple,but they don't consider the object size. A size-based algorithmremoves big objects (that require much memory), but the byte-hitrate will be low. It's important to consider all the Webapplication's requirements before deciding which cache algorithm touse for expiring cached objects.

 

八、缓存实现的位置:
    In distributed system such as a J2EE application, two forms ofcaching can exist: client-side and server-sidecaching. Client-side caching is useful for saving the networkbandwidth and the time required to repeatedly transmit server datato the client. On the other hand, server-side caching is usefulwhen many client requests lead to repeated acquisitions of the sameresource in the server. Server-side caching can be achieved in anytier, i.e., database, application server, servlet container, andWeb server.

 

九、缓存对多个JVM时所要注意的问题(缓存的数据同步的问题):
    Object caching in a cluster is important because multiple JVMs runin a cluster, and keeping all the cluster members' cached data insync is crucial. Since each servlet container has a cache managerinstance in its JVM, data changes must be reflected in all cachesto prevent stale reads. This can be achieved by using amessage-driven bean (MDB) to notify all of the cache managers whento refresh the cached data. Many caching frameworks providebuilt-in cluster support for caching data.

 

十、一个缓存Framework实现时所要达到的目标:
    *Faster access to frequently used data in the Web portalapplication.

    * Groupingof similar object types in the cache. The framework shouldinvalidate a collection of objects with a single operation. Itshould be possible to associate objects in the cache so they can bemanaged as a group. In particular, invalidating a group of objectswith one call should also be feasible.
    *Configurable cache management so I can modify cache parametersdeclaratively rather than programmatically.
    * Easyintegration into any Web application with minimal or no changes inthe Web application itself.
    * Seamlessexpiration mechanism. The hard part of expiration should be in theframework. Using the framework to expire objects should be as easyas possible.
    * Thecaching system shouldn't require the objects it stores tounderstand timestamps and know when they are out of date.
    * A flexibleand extensible framework so I can switch to any third-party cachingAPI in the future.
    *Flexibility to configure one or more data storage options, such asmemory cache, disk cache, or caching the data on a remotemachine.
    * Ability togenerate statistics to monitor both caching effectiveness andapplication performance improvement as a result of datacaching.
    * Ability tomanage objects loaded from any source. The original source of thedata being cached should have no restrictions.

 

参考http://blog.sina.com.cn/s/blog_4abc544f0100m1ng.html

原文地址:https://www.cnblogs.com/orientsun/p/2609903.html