mybatis整合memcache

We have just released the 1st GA version of the MyBatis Memcached adapter.java

The beta has bee around for almost one year and only one issue was reported.git

這個memcache的整合是官方發佈的版本,在網上找了找都沒看到相關介紹,我此次也當次搬運工github

pom文件引用緩存

<dependency>
    <groupId>org.mybatis.caches</groupId>
    <artifactId>mybatis-memcached</artifactId>
    <version>1.0.0</version>
  </dependency>

也能夠上github上下載https://github.com/mybatis/memcached-cache/releases mybatis

http://mybatis.github.io/memcached-cache/ 這個是說明app

在mapper中配置異步

<mapper namespace="org.acme.FooMapper">
  <cache type="org.mybatis.caches.memcached.MemcachedCache" />
  ...
</mapper>

memcache的配置是根據classpath下的 /memcached.properties 配置的,若是沒有使用默認async

Property Default Description
org.mybatis.caches.memcached.keyprefix _mybatis_ 緩存key的前綴
org.mybatis.caches.memcached.servers localhost:11211 memcache配置${host}:${port}
org.mybatis.caches.memcached.connectionfactory net.spy.memcached.DefaultConnectionFactory 只要是實現接口net.spy.memcached.ConnectionFactory
org.mybatis.caches.memcached.expiration 過時時間
單位是秒
org.mybatis.caches.memcached.asyncget false 是否啓用異步讀
org.mybatis.caches.memcached.timeout 5 使用異步讀的timeout時間
org.mybatis.caches.memcached.timeoutunit java.util.concurrent.TimeUnit.SECONDS timeout單位
org.mybatis.caches.memcached.compression false 若是開啓,對象在放到memcache前會使用GZIP 壓縮



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

<mapper namespace="org.acme.FooMapper">
  <cache type="org.mybatis.caches.memcached.LoggingMemcachedCache" />
  ...
</mapper>


還沒看代碼是怎麼實現的,是否是能夠實現那種hibernate的二級緩存功能spa

相關文章
相關標籤/搜索