redis整合springboot

2021-03-13 01:31

阅读:531

标签:default   tco   def   spring   utils   pen   tor   disco   etc   

redis参照processon图,包含redis知识库。
https://www.processon.com/mindmap/5fab94d77d9c0865e9bc7838

依赖中配置

org.springframework.boot
spring-boot-starter-data-redis

public String getDBStr(int db, String key) {
RedisConnectionFactory connectionFactory = redisTemplate.getConnectionFactory();
RedisConnection redisConnection = RedisConnectionUtils.bindConnection(connectionFactory);
DefaultStringRedisConnection stringRedisConnection = new DefaultStringRedisConnection(redisConnection);
stringRedisConnection.select(db);
return stringRedisConnection.get(key);
}

public void setDBStr(int db, String key, String value) {
RedisConnectionFactory connectionFactory = redisTemplate.getConnectionFactory();
RedisConnection redisConnection = RedisConnectionUtils.bindConnection(connectionFactory);
DefaultStringRedisConnection stringRedisConnection = new DefaultStringRedisConnection(redisConnection);
stringRedisConnection.select(db);
stringRedisConnection.set(key, value);
}

redis整合springboot

标签:default   tco   def   spring   utils   pen   tor   disco   etc   

原文地址:https://www.cnblogs.com/stubborn-dude/p/13959849.html


评论


亲,登录后才可以留言!