December 19, 2014
Hot Topics:

Caching Solutions in Java

  • September 20, 2007
  • By Aleksey Shevchenko
  • Send Email »
  • More Articles »

3. Jofti

Some of the salient features of Jofti are:

  1. 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.
  2. The indexing mechanism provided by Jofti works fine with frequent updates to it.
  3. Jofti provides an easy-to-use programming interface.
  4. It doesn't provide a cache implementation on its own. However, any cache implementation can be plugged into the indexing mechanism.
  5. The following cache implementations are currently supported by Jofti:
    • EHCache
    • OSCache
    • 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.

Because Jofti doesn't have its own cache implementation, it depends on the implementations of the plugged product.

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).

3.2 Configuration

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.

4. ShiftOne

  • 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:

  1. EHCache
  2. SwarmCache
  3. JCS Cache
  4. 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.

5. WhirlyCache

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.

6. SwarmCache

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



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Rocket Fuel