Monday, June 14, 2010

Writing wrapper of caching frameworks, part1

My presentation was last week and I told about the design of the caching system for the logic service. As you know I`ll use a widely used caching framework which helps me to cover a bigger part of the requirements such:

  • provide an inmemory cache
  • provide a disk cache
  • expiration time for cache objects and so on.

Also one of the tasks was to design an abstraction layer for a caching framework to have opportunity to change it. We needn`t all of features of any caching framework (ehcache, jboss cache, jcs ...) and we will use only framework`s cache to get/put objects, cache manager to create caches and configuration objects to change some run time properties of the cache.

I tried to use ehcache, then I looked through the tutorial of the jboss-cache and jcs. I understood they similar in their using. All of them have configuration files to configure some central object in the meaning of the cache manager, using it we can create caches and change their configurations.

Below I provided simplified structures of ehcache and jboss-cache.

EhCache:

Using an ehcache.xml file we can create a CacheManager then we can get/create caches using the CacheManager. That`s all! we can put/get objects into/from a cache. Each cache has it`s configuration and some properties may be changed at run time.

JBoss-cache:

Using a CacheFactory and some config.xml file we can create a Cache. This cache is like a CacheManager. It has at least one ROOT node and may have a lot of them each node we can use like a cache where we can put/get objects.

There is a similar situation with jcs.

Next post I`ll write about my design to wrap caching framework.

No comments:

Post a Comment