jedis-2.7.0.jar
apache.commons.pool2-2.2.jar
springframework.data.redis-1.5.0.jar
2.spring整合redis配置
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
3.代码示例
//spring 整合redis
public class RedisIntegrateDemo {
public static void main(String[] args) {
ApplicationContext ctx = new ClassPathXmlApplicationContext("/my/config/spring-bean-services-redis.xml");
StringRedisTemplate template = ctx.getBean(StringRedisTemplate.class);
//增
template.opsForHash().put("omg", "wq", "sm");
template.opsForHash().put("omg", "key1", "v1");
//删
template.opsForHash().delete("omg", "wq");
//改
template.opsForHash().put("omg", "key1", "v1-1");
//查
System.out.println(template.opsForHash().get("omg", "key1"));
}
}