Spring RedisTemplate操作-String操作(2)
@Autowired
@Resource(name="redisTemplate")
private RedisTemplate<String, String> rt; public void flushdb(){
rt.execute(new RedisCallback<Object>() {
public String doInRedis(RedisConnection connection) throws DataAccessException {
connection.flushDb();
return "ok";
}
});
} public void set(){
flushdb();
ValueOperations<String, String> vo = rt.opsForValue();
vo.set("wzg", "nihao");
vo.set("wzg", "nihao",3);
vo.set("wzg2", "nihao",2,TimeUnit.MINUTES);
vo.set("mc", "nihao");
vo.setIfAbsent("wzg", "dsg");
Map<String, String> map = new HashMap<String, String>();
map.put("cff", "xsg");
map.put("cl", "xxsg");
vo.multiSet(map);
vo.append("cff", " sm");
vo.increment("age", 2);
vo.increment("age", 1);
vo.increment("age", -1);
rt.delete("mc");
rt.convertAndSend("redisss", "niyashabi");
rt.setEnableTransactionSupport(true);
} public void get(){
ValueOperations<String, String> vo = rt.opsForValue();
out(vo.get("wzg"));
out(vo.get("wzg",1,2));
out(vo.getAndSet("wzg", "hello"));
out(vo.get("wzg"));
out(vo.multiGet(Arrays.asList("cff","cl")));
// out(vo.get("age"));
out(vo.size("wzg"));
out(vo.get("mc"));
out(rt.keys("*"));
out(rt.randomKey());
out(rt.getClientList());
out(rt.hasKey("wzg"));
out(rt.type("wzg")); // try {
// Thread.sleep(2000);
// } catch (InterruptedException e) {
// }
// out(rt.getExpire("wzg2"));
}
Spring RedisTemplate操作-String操作(2)的更多相关文章
- Redis一(Redis-py与String操作)
Redis 介绍 redis是一个key-value存储系统.和Memcached类似,它支持存储的value类型相对更多,包括string(字符串).list(链表).set(集合).zset(so ...
- redis python 操作 Python操作Redis数据库
原文章于此:https://www.cnblogs.com/cnkai/p/7642787.html 有个人修改与改正 Python操作Redis数据库 连接数据库 StrictRedisfrom ...
- 曹工说Spring Boot源码(20)-- 码网灰灰,疏而不漏,如何记录Spring RedisTemplate每次操作日志
写在前面的话 相关背景及资源: 曹工说Spring Boot源码(1)-- Bean Definition到底是什么,附spring思维导图分享 曹工说Spring Boot源码(2)-- Bean ...
- Spring RedisTemplate操作-xml配置(1)
网上没能找到全的spring redistemplate操作例子,故特意化了点时间做了接口调用练习,基本包含了所有redistemplate方法. 该操作例子是个系列,该片为spring xml配置, ...
- RedisTemplate的各种操作(set、hash、list、string)
RedisTemplate的各种操作(set.hash.list.string) 注入以下RedisTemplate @Autowired private RedisTemplate<Strin ...
- springboot之使用redistemplate优雅地操作redis
概述 本文内容主要 关于spring-redis 关于redis的key设计 redis的基本数据结构 介绍redis与springboot的整合 sringboot中的redistemplate的使 ...
- Spring 对JDBC操作的支持
1.Spring 对JDBC操作的支持 Spring对jdbc技术提供了很好的支持,体现在: 1.Spring对c3p0连接池的支持很完善 2.Spring对jdbc提供了jdbcTemplate,来 ...
- spring对数据库的操作、spring中事务管理的介绍与操作
jdbcTemplate的入门 创建maven工程 此处省略 导入依赖 <!-- https://mvnrepository.com/artifact/org.springframework/s ...
- Spring中的JDBC操作
一.Spring模板JdbcTemplate 为了使 JDBC 更加易于使用, Spring 在 JDBC API 上定义了一个抽象层, 以此建立一个 JDBC 存取框架JdbcTemplate. 作 ...
随机推荐
- Stm32l151+mpu6050+uart读取数据调试
新近买了一个MPU6050模块,如上图,这个模块上的三块黑色分别是:稳压芯片662K,STM8s003f3p6,MPU6050. 根据此模块的说明书,可以使用USB转TTL将模块与上位机连接,通过卖家 ...
- Unity导入模型出现 (Avatar Rig Configuration mis-match. Bone length in configuration does not match position in animation)?
昨天遇到这两个模型导入的问题,查了一下资料,自己摸索了一下解决方法..总结一下~ 出现的原因:(问题1)Warning 当模型文件导入以后并且设置Animation Type是Generic的时候,动 ...
- unity2D背景移动补偿从而获得3d错觉效果
2d平台跳跃游戏当相机移动的时候背景跟随进行微调移动,从而使得玩家获得3d的错觉 using System.Collections;using System.Collections.Generic;u ...
- error: Build input file cannot be found: '*******/node_modules/react-native/Libraries/WebSocket/libfishhook.a' 问题解决记录
解决了刚才的'config.h' file not found问题,本以为就可以顺畅的跑起来,谁知道又被恶心到了,Build input file cannot be found!!! 问题: err ...
- 2-Eleventh Scrum Meeting20151211
第二阶段任务分工整理会议 1.会议任务: (1)明晰第二阶段的开发内容,统计未完成的功能留需完善开发. (2)安排任务分工,每个人的工作安排. (3)PM职位担任. (4)博客内容负责. 2.会议记录 ...
- 微信小程序input组件抖动及textarea组件光标错位解决方案
问题一: 使用微信小程序input组件时,在移动端唤起focus或blur事件时,因光标占位导致内容出现叠影及抖动现象. 解决方案: 用<textarea>组件代替了<input/& ...
- 安全相关论文--Security and Dependability
安全相关论文--Security and Dependability 所参考的文献来自于Kreutz D, Ramos F M V, Esteves Verissimo P, et al. Softw ...
- vue 有关框架
iview-admin https://github.com/iview/iview-admin/ axios https://www.kancloud.cn/yunye/axios/234845
- linux客户端WinSCP
WinSCP是一个Windows环境下使用SSH的开源图形化SFTP客户端.同时支持SCP协议.它的主要功能就是在本地与远程计算机间安全的复制文件. 这是一个中文版的介绍.从这里链接出去的大多数文 ...
- CentOS系统下安装 LNAM环境
系统需求: CentOS/RHEL/Fedora/Debian/Ubuntu/Raspbian Linux系统 需要3GB以上硬盘剩余空间 128M以上内存,Xen的需要有SWAP,OpenVZ的另外 ...