My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
Caches  
3rd part cache implementations integration
Updated Dec 31, 2010 by simone.t...@gmail.com

Introduction

The MyBatis community supports as well 3rd part cache implementations, follow below which one are currently supported in the 1.0.0 release:

Ehcache

Ehcache is a widely used java distributed cache for general purpose caching, Java EE and light-weight containers.

The Ehcache integration is built on top of the ehcache-core and comes without any Ehcache 3rd part applications. Please refeer to official Ehcache documentation if you need Ehcache plugins.

Users that want to use Ehcache into their applications, have to download the zip bundle, decompress it and add the jars in the classpath; Apache Maven users instead can simply add in the pom.xml the following dependency:

<dependencies>
    ...
    <dependency>
        <groupId>org.mybatis</groupId>
        <artifactId>mybatis-ehcache</artifactId>
        <version>1.0.0</version>
    </dependency>
    ...
</dependencies>

then, just configure it in the mapper XML:

<mapper namespace="org.acme.FooMapper">

    <cache type="org.mybatis.caches.ehcache.EhcacheCache"/>

    ...

</mapper>

If users need to log cache operations, they can plug the Cache logging version:

<mapper namespace="org.acme.FooMapper">

    <cache type="org.mybatis.caches.ehcache.LoggingEhcacheCache"/>

    ...

</mapper>

Users that need to configure Ehcache through XML configuration file, have to put in the classpath the /ehcache.xml resource; please refeer to the official Ehcache documentation to know more details.

Hazelcast

Hazelcast is an open source clustering and highly scalable data distribution platform for Java.

Users that want to use Hazelcast into their applications, have to download the zip bundle, decompress it and add the jars in the classpath; Apache Maven users instead can simply add in the pom.xml the following dependency:

<dependencies>
    ...
    <dependency>
        <groupId>org.mybatis</groupId>
        <artifactId>mybatis-hazelcast</artifactId>
        <version>1.0.0</version>
    </dependency>
    ...
</dependencies>

then, just configure it in the mapper XML:

<mapper namespace="org.acme.FooMapper">

    <cache type="org.mybatis.caches.hazelcast.HazelcastCache"/>

    ...

</mapper>

If users need to log cache operations, they can plug the Cache logging version:

<mapper namespace="org.acme.FooMapper">

    <cache type="org.mybatis.caches.hazelcast.LoggingHazelcastCache"/>

    ...

</mapper>

Please refer to the official Hazelcast Near Cache documentation to know more details how to configure Hazelcast as Cache.

OSCache

OSCache is a high performances caching solution developed and maintained by Open Symphony and easily integrated in MyBatis since the iBATIS version 2.X.

Users that want to use OSCache into their applications, have to download the zip bundle, decompress it and add the jars in the classpath; Apache Maven users instead can simply add in the pom.xm the following dependency:

<dependencies>
    ...
    <dependency>
        <groupId>org.mybatis</groupId>
        <artifactId>mybatis-oscace</artifactId>
        <version>1.0.0</version>
    </dependency>
    ...
</dependencies>

then, just configure it in the mapper XML:

<mapper namespace="org.acme.FooMapper">

    <cache type="org.mybatis.caches.oscache.OSCache"/>

    ...

</mapper>

If users need to log cache operations, they can plug the Cache logging version:

<mapper namespace="org.acme.FooMapper">

    <cache type="org.mybatis.caches.oscache.LoggingOSCache"/>

    ...

</mapper>

For proper OSCache configuration please read the official reference

Comment by KrisSad...@gmail.com, Jun 11, 2011

I love MyIbatis? now. This is Great Framework. Keep spirits !!!

Comment by dengfe...@gmail.com, Jun 16, 2011

me too.


Sign in to add a comment
Powered by Google Project Hosting