资源简介
本资源是一个最新 spring4 + mybatis3 + Redis 缓存集成的一个简单的 demo,也是博客《Redis 缓存 + Spring 的集成示例》的配套示例项目,该博客地址是:http://blog.csdn.net/defonds/article/details/48716161。
代码片段和文件信息
/**
* File Name:RedisCacheConfig.java
*
* Copyright Defonds Corporation 2015
* All Rights Reserved
*
*/
package com.defonds.bdp.cache.redis;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.interceptor.KeyGenerator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.cache.RedisCacheManager;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import java.lang.reflect.Method;
/**
*
* Project Name:bdp
* Type Name:RedisCacheConfig
* Type Description:
* Author:Defonds
* Create Date:2015-09-21
*
* @version
*
*/
@Configuration
@EnableCaching
public class RedisCacheConfig extends CachingConfigurerSupport {
@Bean
public JedisConnectionFactory redisConnectionFactory() {
JedisConnectionFactory redisConnectionFactory = new JedisConnectionFactory();
// Defaults
redisConnectionFactory.setHostName(“192.168.1.166“);
redisConnectionFactory.setPort(6379);
return redisConnectionFactory;
}
@Bean
public RedisTemplate redisTemplate(RedisConnectionFactory cf) {
RedisTemplate redisTemplate = new RedisTemplate();
redisTemplate.setConnectionFactory(cf);
return redisTemplate;
}
@Bean
public CacheManager cacheManager(RedisTemplate redisTemplate) {
RedisCacheManager cacheManager = new RedisCacheManager(redisTemplate);
// Number of seconds before expiration. Defaults to unlimited (0)
cacheManager.setDefaultExpiration(3000); // Sets the default expire time (in seconds)
return cacheManager;
}
@Bean
public KeyGenerator customKeyGenerator() {
return new KeyGenerator() {
@Override
public object generate(object o Method method object... objects) {
StringBuilder sb = new StringBuilder();
sb.append(o.getClass().getName());
sb.append(method.getName());
for (object obj : objects) {
sb.append(obj.toString());
}
return sb.toString();
}
};
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2015-09-24 19:57 bdp\
文件 1213 2015-09-18 17:50 bdp\.classpath
文件 1212 2015-09-18 14:15 bdp\.project
目录 0 2015-09-24 19:55 bdp\.settings\
文件 503 2015-09-18 11:47 bdp\.settings\.jsdtscope
文件 162 2015-09-22 18:14 bdp\.settings\org.eclipse.core.resources.prefs
文件 430 2015-09-18 14:15 bdp\.settings\org.eclipse.jdt.core.prefs
文件 90 2015-09-18 14:15 bdp\.settings\org.eclipse.m2e.core.prefs
文件 830 2015-09-18 17:50 bdp\.settings\org.eclipse.wst.common.component
文件 345 2015-09-18 11:47 bdp\.settings\org.eclipse.wst.common.project.facet.core.xm
文件 49 2015-09-18 11:47 bdp\.settings\org.eclipse.wst.jsdt.ui.superType.container
文件 6 2015-09-18 11:47 bdp\.settings\org.eclipse.wst.jsdt.ui.superType.name
文件 50 2015-09-18 14:16 bdp\.settings\org.eclipse.wst.validation.prefs
目录 0 2015-09-24 19:57 bdp\jmeter\
文件 8167 2015-09-23 16:39 bdp\jmeter\deleteCity.jmx
文件 10541 2015-09-24 10:45 bdp\jmeter\insertCity.jmx
文件 8181 2015-09-24 19:25 bdp\jmeter\provinceCities.jmx
文件 8650 2015-09-24 19:36 bdp\jmeter\renameCity.jmx
文件 8165 2015-09-24 19:25 bdp\jmeter\searchCity.jmx
文件 4325 2015-09-24 11:07 bdp\pom.xm
文件 822 2015-09-24 19:59 bdp\readme.txt
目录 0 2015-09-24 19:55 bdp\src\
目录 0 2015-09-24 19:55 bdp\src\main\
目录 0 2015-09-24 19:55 bdp\src\main\java\
目录 0 2015-09-24 19:55 bdp\src\main\java\com\
目录 0 2015-09-24 19:55 bdp\src\main\java\com\defonds\
目录 0 2015-09-24 19:55 bdp\src\main\java\com\defonds\bdp\
目录 0 2015-09-24 19:55 bdp\src\main\java\com\defonds\bdp\cache\
目录 0 2015-09-24 19:55 bdp\src\main\java\com\defonds\bdp\cache\redis\
文件 2401 2015-09-24 11:47 bdp\src\main\java\com\defonds\bdp\cache\redis\RedisCacheConfig.java
目录 0 2015-09-24 19:55 bdp\src\main\java\com\defonds\bdp\city\
............此处省略79个文件信息
相关资源
- redisson的demo
- Spring-Data-Redis2.0+Spring5
- mongodb+redis资源
- redis安装包
- 破解ServiceStack.Redis每小时6000次限制
- redis for Windows
- 爱旅行项目源码
- The Apache Ignite book PDF(正版购买的全网
- vcredist2010_x64
- redis-4.0.9.tar
- 使用redisson替代jedis
- .NET下Redis操作类
- (龙果学院)从无到有搭建中小型互
- 数字预失真设计参考Mixed Signal Digita
- redisplus 3.2 客户端
- 狂神说Redis笔记.pdf
- 基于SSM的校社联社团管理系统SpringM
- 大规模redis集群的服务治理之路
- Redis哨兵模式sentinel学习总结及部署记
- redis-5.0.2.tar.gz
- Twemproxy需要的依赖,加Redis安装包,
- springboot整合mybatis+plus+avtiveMq+redis
- Redis-x64-3.2.100安装.zip
- pc6-vcredist_x86
- redis-5.0.8-x64-for-windows.zip
- windows下64位的redis-2.8.12
- redis-3.2.9.tar.gz
- 分布式集群Session共享 简单多tomcat8+
- redis64-latest.zip
- 最新 redis-4.0.2.tar.gz 包
评论
共有 条评论