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. 作 ...
随机推荐
- eclipse + maven + com.sun.jersey 创建 restful api
maven 创建 jersey 项目 如果没找到 jersey archetype, 下载 maven 的 archetype xml, 然后导入 archetypes 运行 右击 main.java ...
- .NET Core 开发之旅 (1. .NET Core R2安装教程及Hello示例)
前言 前几天.NET Core发布了.NET Core 1.0.1 R2 预览版,之前想着有时间尝试下.NET Core.由于各种原因,就没有初试.刚好,前几天看到.NET Core发布新版本了,决定 ...
- Apache Ignite 学习笔记(一): Ignite介绍、部署安装和REST/SQL客户端使用
Apache Ignite 介绍 Ignite是什么呢?先引用一段官网关于Ignite的描述: Ignite is memory-centric distributed database, cachi ...
- 父类与子类this相关问题
1.SinglyLinkedList: package No3_PolySinglyList; /*实现 带头结点的单链表SinglyLinkedList类*/ public class Singly ...
- YQCB冲刺第二周绩效评价
标准队员 工作质量 20% 工作态度 20% 工作量 30% 工作难易程度 20% 团队意识 10% 总分 陈美琪 17 18 24 17 9 85 张晨阳 19 19 27 19 9 93 刘昭为 ...
- 将搬家至CSDN
emmm,感觉没利用好博客,自己也弄了一个github上面的hexo博客https://clarkkun.github.io/,但是死活传不上去内容,尴尬 ̄□ ̄||,三个博客齐头并进吧
- 结巴分词python
将文件中的txt文档依次读出 并分好词后 写入 另外的TXT中 #coding=utf-8 import os import jieba import codecs import random def ...
- C#使用结构体,输入5个人的学号,姓名,分数,按照成绩高低排列打印出来
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- 团队冲刺随笔合集—Beta阶段
第一篇:http://www.cnblogs.com/Team-Blog/p/9049271.html 第二篇:https://www.cnblogs.com/Team-Blog/p/9064478. ...
- springmvc关于redisCluster的使用及配置
首先附上maven仓库jar包的下载地址:https://repo.spring.io/webapp/#/artifacts/browse/tree/General/libs-release-loca ...