Redis与spring整合缓存的业务场景使用方法二(使用注解@Cacheable@CacheEvict)
来源:互联网 发布:python量化交易 github 编辑:程序博客网 时间:2024/05/29 10:38
一:配置appliction-redis.xml
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:jdbc="http://www.springframework.org/schema/jdbc"xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util" xmlns:task="http://www.springframework.org/schema/task"xmlns:cache="http://www.springframework.org/schema/cache" xmlns:c='http://www.springframework.org/schema/c'xmlns:p="http://www.springframework.org/schema/p"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsdhttp://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.0.xsdhttp://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsdhttp://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsdhttp://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.0.xsdhttp://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-3.1.xsd"default-lazy-init="true"><!-- 开启spring cache注解功能--><cache:annotation-driven cache-manager="redisCacheManager" /><context:annotation-config/><context:property-placeholder ignore-unresolvable="true" location="classpath:config.properties" /><!-- Redis --><bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig"/><bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"><property name="hostName" value="${redis.hostName}" /><property name="port" value="${redis.port}" /><property name="password" value="${redis.password}" /><property name="timeout" value="${redis.timeout}" /><property name="usePool" value="${redis.usePool}" /><property name="poolConfig" ref="jedisPoolConfig" /></bean><bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate" ><property name="connectionFactory" ref="jedisConnectionFactory"/></bean> <!-- redis缓存管理器 --><bean id="redisCacheManager" class="org.springframework.data.redis.cache.RedisCacheManager"> <constructor-arg name="redisOperations" ref="redisTemplate" /> </bean></beans>二:在业务层添加注解
三:测试缓存
其实用这种方法,只要了解注解的含义,用起来很方便。比第一种方法方便太多,当然你也可以使用AOP的思想,自己进行自定义注解,并使用,下篇说明
0 0
- Redis与spring整合缓存的业务场景使用方法二(使用注解@Cacheable@CacheEvict)
- spring整合redis缓存,以注解(@Cacheable、@CachePut、@CacheEvict)形式使用
- spring整合redis缓存,以注解(@Cacheable、@CachePut、@CacheEvict)形式使用
- spring整合redis缓存,以注解(@Cacheable、@CachePut、@CacheEvict)形式使用
- Spring缓存注解@Cacheable、@CacheEvict、@CachePut使用
- Spring缓存注解@Cacheable,@CachePut , @CacheEvict使用
- Spring 缓存注解(@Cacheable、@CachePut、@CacheEvict)使用
- Spring缓存注解@Cacheable、@CacheEvict、@CachePut使用
- Spring缓存注解@Cacheable、@CacheEvict、@CachePut使用
- Spring缓存注解@Cacheable、@CacheEvict、@CachePut使用
- Spring缓存注解@Cacheable、@CacheEvict、@CachePut使用
- Spring缓存注解@Cacheable、@CacheEvict、@CachePut使用
- Redis与spring整合缓存的业务场景使用方法一
- Spring注解@Cacheable、@CachePut、@CacheEvict的使用
- Spring缓存注解@Cacheable、@CacheEvict、@CachePut使用注意点
- Spring缓存注解@Cacheable、@CachePut和@CacheEvict
- Spring缓存注解@Cacheable,@CachePut , @CacheEvict介绍
- 使用spring自带的Cacheable注解处理Redis缓存
- Json字符串和js对象之间的转换
- iOS 利用token保持登陆状态
- 给ubuntu14.04Desktop 64Bit版本加一个硬盘(原始的LOG文件)
- 预处理命令
- 支付效果实现
- Redis与spring整合缓存的业务场景使用方法二(使用注解@Cacheable@CacheEvict)
- java开发调用iReport生成Html报表
- Hi3518开发板开发总结
- 图形化界面创建
- 浅谈web应用的负载均衡、集群、高可用(HA)解决方案
- (转)深入理解JavaScript系列(4):立即调用的函数表达式
- 2017年第八届山东省ACM大学生程序设计竞赛后记
- sqlserver 分页
- 给ubuntu14.04Desktop 64Bit版本加一个硬盘(草稿版本)