hibernate-memcached(http://code.google.com/p/hibernate-memcached/
)是允许hibernate使用MemCached作为二级缓存的项目,它用到了spymemcached(http://code.google.com/p/spymemcached/
)这个MemCached的Java客户端。花了一点时间做了个补丁,让它也支持Whalin的Java客户端(http://whalin.com/memcached/
)。
所有的代码(包括原hibernate-memcached的所有源码)、javadoc及重新制作的发布包请见附件,限于篇幅就不具体说明了。以下是我更新过的hibernate-memcached的配置说明,原配置说明请参见http://code.google.com/p/hibernate-memcached/wiki/Configuration
If you are using Maven2 for your application build you can follow the instructions on the
MavenRepository
page. For those that aren't using Maven2 you'll need to collect a few
simple jars for yourself. I am going to assume you already have
hibenrnate3 setup before you came here.
You'll need...
If you are using spymemcached
as the MemCached client, you also need
or if you prefer Whalin's
memcached client for java
, you need to download java_memcached-release_2.0.1.jar from the
download page
according to your Java VM version.
The first thing to do is to tell hibernate which cache provider you'd like to use, and to enable the second level cache.
hibernate.cache.provider_class |
com.googlecode.hibernate.memcached.MemcachedCacheProvider |
Using just the property above you get
basic entity caching by default. The hibernate-memcached library
supports query caching, but you have to enable query caching
separately.
hibernate.cache.use_query_cache |
true |
!Now you can start setting up the
hibernate-memcached specific properties. The hibernate-memcached
properties are divided into two categories; cache-wide settings and
cache-region settings.
The cache wide settings all have
defaults can mostly be overwritten at a cache-region level. For both
spymemcached and Whalin's client, you can set:
Property
|
Default
|
Description
|
hibernate.memcached.servers |
localhost:11211 |
Space delimited list of memcached instances in host:port format |
hibernate.memcached.cacheTimeSeconds |
300 |
The default number of seconds items should be cached. Can be overriden at the regon level. |
hibernate.memcached.keyStrategy |
HashCodeKeyStrategy |
Sets the strategy class to to use for generating cache keys. Must provide a class name that implements KeyStrategy |
hibernate.memcached.clearSupported |
false |
Enables support for the MemcachedCache.clear() method for all cache
regions. The way clear is implemented for memcached is expensive and
adds overhead to all get/set operations. It is not recommended for
production use. |
For spymemcached, you can set:
hibernate.memcached.readBufferSize |
DefaultConnectionFactory.DEFAULT_READ_BUFFER_SIZE |
The read buffer size for each server connection from this factory |
hibernate.memcached.operationQueueLength |
DefaultConnectionFactory.DEFAULT_OP_QUEUE_LEN |
Maximum length of the operation queue returned by this connection factory |
hibernate.memcached.operationTimeout |
DefaultConnectionFactory.DEFAULT_OPERATION_TIMEOUT |
Default operation timeout in milliseconds |
hibernate.memcached.hashAlgorithm |
HashAlgorithm.KETAMA_HASH |
Which hash algorithm to use when adding items to the cache. Note: the
MemcachedClient defaults to using HashAlgorithm.NATIVE_HASH, while the
hibernate-memcached cache defaults to KETAMA_HASH for "consistent
hashing" |
For Whalin's client, you can set:
hibernate.memcached.weights
|
|
Space delimited list of server weights. If not set, all servers get the same weight
|
hibernate.memcached.errorHandler
|
com.googlecode.hibernate.memcached.
dangamemcached.SimpleErrorHandler
|
Error handler used by Whalin's client internally
|
hibernate.memcached.poolName
|
default
|
The name of SockIOPool
|
hibernate.memcached.initConn
|
1
|
Initial pool size
|
hibernate.memcached.minConn
|
1
|
Min pool size
|
hibernate.memcached.maxConn
|
10
|
Max pool size
|
hibernate.memcached.maxIdle
|
3000000
|
Max idle time for available sockets. Default 5 minutes
|
hibernate.memcached.socketTimeout
|
30000
|
Default timeout of socket reads. Default 30 seconds
|
hibernate.memcached.socketConnectTimeout
|
3000
|
Default timeout of socket connections. Default 3 seconds
|
hibernate.memcached.maintSleep
|
30000
|
Maintenance thread sleep time. Default 30 seconds
|
hibernate.memcached.compressEnable
|
true
|
If compression enabled
|
hibernate.memcached.defaultEncoding
|
UTF-8
|
Default encoding
|
Cache regon properties are set by
giving your cached data a "region name" in hibernate. You can tune the
MemcachedCache instance for your region using the following properties.
These properties essentially override the cache-wide properties above.
Property
|
Default
|
Description
|
hibernate.memcached.[region-name].cacheTimeSeconds |
none, see hibernate.memcached.cacheTimeSeconds |
Set the cache time for this cache region, overriding the cache-wide setting. |
hibernate.memcached.[region-name].keyStrategy |
none, see hibernate.memcached.keyStrategy |
Overrides the strategy class to to use for generating cache keys in
this cache region. Must provide a class name that implements
KeyStrategy |
hibernate.memcached.[region-name].clearSupported |
none, see hibernate.memcached.clearSupported |
Enables clear() operations for this cache region only. Again, the clear operation incurs cost on every get/set operation. |
分享到:
相关推荐
hibernate-memcached, 在Hibernate中,使用Memcached作为第二级分布式缓存的库 休眠 memcachedHibernate中使用...基于优秀的spymemcached客户端包含对 Whalin ( danga ) memcached客户端的支持支持实体和查询缓存。帮
Memcached的java客户端已经存在三种了: 1.官方提供的基于传统阻塞io由Greg Whalin维护的客户端。 较早推出的memcached JAVA客户端API,应用广泛,运行比较稳定。 2.spymemcached,支持异步,单线程的memcached客户端...
它还提供了丰富的特性,如支持完整的协议、客户端分布、节点权重设置、动态增删节点、JMX支持、Spring和Hibernate-memcached集成、连接池功能以及良好的可扩展性。 **推荐与建议** 考虑到官方客户端的新版本在性能...
memcached客户端,[✓] Redis-Jedis客户端,[x] Redis-Redisson JDBC指标[✓]通用JDBC驱动程序 连接池指标[X] C3PO,[X] HikraiCP NoSQL数据库[X]卡桑德拉,[X]蒙哥 URL连接指标[✓] java.net.HttpURLConnection,...
以下是常见的C++笔试面试题及其核心知识点解析,帮助您系统复习
计算机短期培训教案.pdf
计算机二级Access笔试题库.pdf
下是一份关于C++毕业答辩的心得总结,内容涵盖技术准备、答辩技巧和注意事项,供参考
内容概要:本文档详细介绍了英特尔为苹果公司构建的基于智能处理单元(IPU)的Cassandra集群的技术验证(PoC)。主要内容涵盖IPU存储用例、已建存储PoC、MEV到MMG400的过渡、苹果构建IPU-Cassandra集群的动机以及PoC开发进展。文档还探讨了硬件配置、软件环境设置、性能调优措施及其成果,特别是针对延迟和吞吐量的优化。此外,文档展示了六节点Cassandra集群的具体架构和测试结果,强调了成本和复杂性的降低。 适合人群:对分布式数据库系统、NoSQL数据库、IPU技术感兴趣的IT专业人员和技术管理人员。 使用场景及目标:适用于希望了解如何利用IPU提升Cassandra集群性能的企业技术人员。主要目标是展示如何通过IPU减少服务器部署的成本和功耗,同时提高数据处理效率。 其他说明:文档中涉及的内容属于机密级别,仅供特定授权人员查阅。文中提到的技术细节和测试结果对于评估IPU在大规模数据中心的应用潜力至关重要。
计算机二级考试C语言题.pdf
计算机发展史.pdf
计算机仿真技术系统的分析方法.pdf
yolo编程相关资源,python编程与YOLO算法组成的坐姿检测系统,功能介绍: 一:实时检测学生错误坐姿人数 二:通过前端阿里云平台显示上传数据,实现数据可视化
办公室网安全监控uptime-kuma,docker镜像离线压缩包
计算机课程设计-网络编程项目源码.zip
将该dll包放入项目并引用,可以操作打印机
杰奇2.3内核淡绿唯美小说网站源码 PC+手机版 自动采集 全站伪静态,送10.1版本关关采集器
计算机辅助教学.pdf
内容概要:本文详细介绍了如何利用天文相机和其他相关硬件设备搭建一套高画质、高帧率的流星监控系统,以及针对红色精灵闪电这一特殊自然现象的捕捉方法。文中不仅涵盖了硬件的选择标准如CMOS靶面尺寸、量子效率等重要参数,还提供了基于Python和OpenCV实现的基本监控代码示例,包括亮度突变检测、运动检测算法等关键技术点。此外,对于安装位置的选择、供电方式、成本控制等方面也有具体的指导建议。 适用人群:对天文摄影感兴趣的爱好者,尤其是希望捕捉流星和红色精灵闪电等瞬时天文现象的专业人士或业余玩家。 使用场景及目标:适用于希望搭建个人天文观测站,用于科学研究或个人兴趣爱好的场景。目标是能够稳定可靠地捕捉到流星和红色精灵闪电等难以捉摸的天文现象,为研究提供高质量的数据资料。 其他说明:文中提到的一些技术和方法虽然较为复杂,但对于有一定编程基础和技术动手能力的人来说是非常实用的参考资料。同时,文中提供的省钱技巧也为预算有限的用户提供了一些有价值的建议。