Caching Solutions in Java, Page 2
Some of the salient features of Jofti are:
- Jofti differs from the other cache implementations in that it provides an indexing mechanism. Hence, to retrieve an Object from the cache, it is queried on one of its properties rather than some arbitrary key.
- The indexing mechanism provided by Jofti works fine with frequent updates to it.
- Jofti provides an easy-to-use programming interface.
- It doesn't provide a cache implementation on its own. However, any cache implementation can be plugged into the indexing mechanism.
- The following cache implementations are currently supported by Jofti:
- JBoss Cache
- Tangosol Coherence
Thus, the above caching products get plugged into Jofti's indexing mechanism. The caching features provided by individual caches are available for use with Jofti. Jofti indexing mechanism can run across multiple caches. The caches can be a local cache or a clustered cache.
3.1 Querying Jofti's Indexing Mechanism
Jofti's provides an exhaustive way to query its index for an Object apart from the traditional querying based on a 'key'. Jofti supports EJB-QL and SQL (ANSI).
Because Jofti is itself doesn't have a caching mechanism on its own, it needs to be configured to use the plugged-in cache product. Jofti can be configured in two ways:
- As a wrapper: In this model, Jofti acts as a adapter for the client. Jofti provides its own API that routes the call to the underneath cache that is plugged into Jofti.
- As a Listener: In this model, the client uses the cache's API for caching. Jofti's index implementation acts as a listener. The index is updated whenever cache's API is invoked.
Jofti provides Transaction Support through JTA implementation. If the cache doesn't support transactional updates, Jofti uses the 'javax.transaction.Synchronization' interface.
- ShiftOne is a lightweight caching framework.
- ShiftOne comes up with a set of cache algorithm implementations namely LRU (Least Recently Used), LFU (Least Frequently Used) and FIFO (First In First Out) algorithms. These algorithms are referred to as 'policy caches'. It provides a means of configuring a third-party caching mechanism into ShiftOne.
- ShiftOne provides a set of decorators that eventually use the underneath caching product to maintain the cache.
The following caching products can be plugged into ShiftOne:
- JCS Cache
- Oro Cache
- ShiftOne supports JMX implementation for collecting statistics.
- Like most of its counterparts, ShiftOne provides an easy programming interface.
- It doesn't support a transactional cache.
- ShiftOne supports a distributed cache.
WhirlyCache provides an in-memory cache. WhirlyCache runs a separate thread to prune the cache; in other words, the data from the cache is not provided by the same application thread that the client uses. Thus, there are fewer burdens on the application thread. WhirlyCache caches all of its data in memory. The background thread is called the tuner thread. There is one tuner thread per cache. The tuner thread can be configured to run after every n seconds. It tries to use the JVM heap to the fullest—the capacity of the cache memory has to be set properly. WhirlyCache doesn't provide a disk overflow feature. To address a memory problem, WhirlyCache uses soft references. The tuner thread scans through its cache to remove any unused references. Underneath, Whirly cache uses FastHashMap and ConcurrentHashMap to maintain soft references to objects that are stored.
5.1 Presentation Layer Caching
WhirlyCache doesn't provide any JSP tag library or PageFragmentFilter to cache part of a JSP. It doesn't provide any HttpResponse cache on the presentation layer.
5.2 Data Layer Caching
WhirlyCache provides caching of domain objects at the Data Access layer. WhirlyCache can be plugged into Hibernate, a popular ORM framework.
Configuration of WhirlyCache can be done in an XML file named 'whirlycache.xml' that comes with a set of default values.
WhirlyCache provides programmatic API to access its cache.
SwarmCache is an in-memory cache intended more for caching domain objects on the data access layer. It offers support for a distributed cache in a clustered environment. When an update/delete happens to a domain object in the cache, the cache manager of the affected cache will communicate to all the other managers in cluster to update their cache. As the number of updates to a cache in the cluster increases, the performance takes a hit. Every update to a cache will result in all the cache managers updating their local cache.
6.1 Presentation layer
SwarmCache has no support for HttpResponse caching. It also doesn't support caching of a page fragment in a dynamic JSP page.
Page 2 of 5