Cache architecture
There are many object cache architectures (including open source and business implementation) Provide distributed cache in the servlet container and application server. Some cache frames that can now be used are listed below:
Open source code project
Java Caching System (JCS) from Jakarta (part of the Turbine project)
Oscache
Commons Collectes (another Jakarta project)
JCache API (SourceForge.net)
Commercial projects
Spiritcache (from spiritsoft).
Coherence (tangosol)
Javlin (Excelon)
Object Caching Service for Java (Oracle)
If you are interested in learning more cache implementations, the last resource section of this article provides the URL of all of these frameworks.
I was initially started to study the framework that met all our cache needs, I saw the Commons Collections and Java Caching System API. The main criterion I started to evaluate is easy to use, easy to expand, and the cost of software. These two frameworks are open source and come from the Apache Jakarta project.
Commons Collectes
The Commons Collections API provides an object cache algorithm in the form of a Java class, named lrumap. If you have only basic needs of the cache, and not really need a lot of extension and cache configuration, Commons Collections may be a non-bad choice, but not the correct choice of an enterprise cache system. If you choose Common Collections to implement an object cache, you will manually define all cache parameters, such as: the number of maximum cache objects, a maximum life cycle of a cache object, refresh cache, or check object fresh interrupt time.
Java caching system
Java Caching System (JCS), part of the Jakarta Turbine project, more mature, more probably compared to Commons Collections. It provides a flexible, configurable solution that enhances the overall system performance by maintaining a dynamic object pool for frequent access to objects. Just as mentioned on its website, JCS has surpassed the scope of simply caching objects in memory. It provides many essential importance for an enterprise-class cache system:
Memory management
Disk overflow (and reorganization)
Element group
Remove quickly nested
Data period management
Scalable frame
Fully configurable runtime parameters
Remote synchronization
Remote storage recovery
An optional horizontal distribution element is implemented via HTTP, TCP or UDP protocol.
JCS provides a fault-free framework that allows full session failover (in the cluster environment), including the SESSION data distribution that supports up to 256 servers. It also provides flexibility to configure one or more data storage options, such as memory cache, disk cache, or cache on the remote machine.
All of this includes excellent features in JCS to make it a good object to meet our web portal projects.
Use JCS Construction Web Portal Cache Framework
Cache Frame
Before I started to design an object cache frame, I first listed the goals that need to be reached in the new framework. The following is the list of targets:
Quickly access frequently used data in the web portal app.
A object similar to the type in the cache is combined.
Provide configurable cache management so that I can modify the parameters instead of encoding by way of ways.
Provides a reliable and scalable frame so that I can convert to other third-party cache APIs in the future.
You can generate statistical data to monitor the efficiency of the cache, and the improvement effect of the performance after using the data cache.
Installing and configuring the JCS in web applications is very simple. Download compressed files from Jakarta Turbine website, unpack files to temporary directory, and copy the jsc.jar file (JCS-1.0-Dev.jar) to the general directory of the servlet container (the servlet container used in my web application is Tomcat, The general directory is under Windows is% tomcat_home% / common / lib, which is $ TOMCAT_HOME / COMMON / LIB under the UNIX type system. You may also need commons-collections.jar, commons-lang.jar, and commons-logging.jar these files exist in a web application classpath to use JCS.
The main principle of the object cache frame is shown in the UML map of Figures 1 and 2.
Figure 1. Object cache sequence diagram
Figure 2. Object Cache Class