mybatis整合mencached
来源:互联网 发布:java读取xml配置文件 编辑:程序博客网 时间:2024/06/08 02:23
官方放出了mybatis和memcached的整合包,先附上官方文档地址
Property Default Description org.mybatis.caches.memcached.keyprefix_mybatis_any string identifierorg.mybatis.caches.memcached.serverslocalhost:11211space separated list of host: {port}org.mybatis.caches.memcached.connectionfactorynet.spy.memcached.DefaultConnectionFactoryAny class that implementsnet.spy.memcached.ConnectionFactoryorg.mybatis.caches.memcached.expirationthe number of seconds in 30 daysthe expiration time (in seconds)org.mybatis.caches.memcached.asyncgetfalseflag to enable/disable the async getorg.mybatis.caches.memcached.timeout5the timeout when using async getorg.mybatis.caches.memcached.timeoutunitjava.util.concurrent.TimeUnit.SECONDSthe timeout unit when using async getorg.mybatis.caches.memcached.compressionfalseif true, objects will be GZIP compressed before putting them to Memcached我简单测试了一下发现它可以配置多个服务器,用逗号分隔,经测试如果某一台挂掉,他会选择正常的那台
http://mybatis.github.io/memcached-cache/
文档很简洁,事实证明使用起来也很简单
memcached的安装我这里就不再讲了,网上很容易找到
在项目中引入
<dependency> <groupId>org.mybatis.caches</groupId> <artifactId>mybatis-memcached</artifactId> <version>1.0.0</version> </dependency>
然后在想使用的mapper中加入
<mapper namespace="org.acme.FooMapper"> <cache type="org.mybatis.caches.memcached.MemcachedCache" /> ...</mapper>
就可以用了
再建一个memcached.properties,对他进行配置
如果2台都挂掉,就会报错,估计我们还是希望在memcached服务器挂掉后从数据库读取数据,不知道大家有什么好的实现方式或者思路吗
org.mybatis.caches.memcached.servers=172.29.33.201:11211,localhost:11211org.mybatis.caches.memcached.expiration=30 org.mybatis.caches.memcached.asyncget=false
0 0
- mybatis整合mencached
- Mencached剖析
- mencached笔记
- mencached属性
- Mybatis -- Mybatis整合Spring
- 【Mybatis】Mybatis整合spring
- 【框架整合】三、整合mybatis
- SpringBoot整合Mybatis(分层整合)
- MyBatis-----2、MyBatis整合Spring
- 【Spring+Mybatis】Spring整合Mybatis
- ehcache和mencached
- Redis vs Mencached
- JAVA操作Mencached实例
- Spring整合Mybatis
- spring整合myBatis
- MyBatis-Spring框架整合
- MyBatis+Spring整合示例
- MyBatis+Spring整合示例
- std::ios_base::Init::Init()”,referenced from 引用C++文件报错
- WCF的应用场景
- GREEN HAND(1)--blink; open lights; water&breath lights; seven segment led; button controls seven seg
- UICollectionViewLayout
- 什么是menuconfig和menuconfig的使用方法和技巧
- mybatis整合mencached
- java se 04
- jQuery 事件
- golang文件读取介绍
- JavaScript实战中会用到的算法
- NoSuchBeanDefinitionException: No qualifying bean of type 错误误区
- U-Boot2010.06移植(2440)-----移植NorFlash驱动
- php的mysql学习(一)
- krpano 全景图在微信里面被屏蔽的解决办法