示例:

@Autowired
StringRedisTemplate redisTemplate; @Override
public void dealRedis(Dealer dealer) { dealer = dao.findByUid(dealer.getUid());
String tid = dealer.getTenementId(); HashOperations<String, Object, Object> ofh = redisTemplate.opsForHash(); Field[] declaredFields = dealer.getClass().getDeclaredFields();
for (Field declaredField : declaredFields) {
String name = declaredField.getName();
if (name.equals("id") || name.equals("tid")){
continue;
}else {
ofh.increment(tid,name,111);
}
}
Map<Object, Object> entries = ofh.entries(tid);
System.out.println("获取Map>>>>>>>>>>>>>>>>>>>>>>>>>>"+entries.toString());
Set<Object> keys = ofh.keys(tid);
System.out.println("获取KEY的SET>>>>>>>>>>>>>>>>>>>>>"+keys.toString());
List<Object> values = ofh.values(tid);
System.out.println("获取VALUES的LIST>>>>>>>>>>>>>>>>>>>>>"+values.toString()); ofh.delete(tid,keys.toArray());
System.out.println("删除成功>>>>>>>>>>>>>>>>>>>>>>>>>>");
Map<Object, Object> entries2 = ofh.entries(tid);
System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>"+entries2.toString()); for (Object key : keys) {
ofh.increment(tid,key,111);
}
Map<Object, Object> entries3 = ofh.entries(tid);
System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>"+entries3.toString()); for (Object key : keys) {
ofh.increment(tid,key,-11);
}
Map<Object, Object> entries4 = ofh.entries(tid);
System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>"+entries4.toString()); ofh.delete(tid,keys.toArray());
System.out.println("删除成功>>>>>>>>>>>>>>>>>>>>>>>>>>"); for (Object key : keys) {
ofh.increment(tid,key,-11);
}
Map<Object, Object> entries5 = ofh.entries(tid);
System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>"+entries5.toString()); }

结果:

【redis】spring boot中 使用redis hash 操作 --- 之 使用redis实现库存的并发有序操作的更多相关文章

  1. 在Spring Boot中使用数据库事务

    我们在前面已经分别介绍了如何在Spring Boot中使用JPA(初识在Spring Boot中使用JPA)以及如何在Spring Boot中输出REST资源(在Spring Boot中输出REST资 ...

  2. 【Spring Boot&&Spring Cloud系列】Spring Boot中使用NoSql数据库Redis

    github地址:https://github.com/AndyFlower/Spring-Boot-Learn/tree/master/spring-boot-nosql-redis 一.加入依赖到 ...

  3. Spring Boot 中 Redis 的使用

    Spring Boot 对常用的数据库支持外,对 Nosql 数据库也进行了封装自动化,如Redis.MongoDB等,本文主要介绍Redis的使用. Redis 介绍 Redis 是目前业界使用最广 ...

  4. Spring Boot中使用Redis小结

    Spring Boot中除了对常用的关系型数据库提供了优秀的自动化支持之外,对于很多NoSQL数据库一样提供了自动化配置的支持,包括:Redis, MongoDB, 等. Redis简单介绍 Redi ...

  5. Spring Boot中使用redis的发布/订阅模式

    原文:https://www.cnblogs.com/meetzy/p/7986956.html redis不仅是一个非常强大的非关系型数据库,它同时还拥有消息中间件的pub/sub功能,在sprin ...

  6. spring boot(三):Spring Boot中Redis的使用

    spring boot对常用的数据库支持外,对nosql 数据库也进行了封装自动化. redis介绍 Redis是目前业界使用最广泛的内存数据存储.相比memcached,Redis支持更丰富的数据结 ...

  7. springboot(三):Spring boot中Redis的使用

    spring boot对常用的数据库支持外,对nosql 数据库也进行了封装自动化. redis介绍 Redis是目前业界使用最广泛的内存数据存储.相比memcached,Redis支持更丰富的数据结 ...

  8. Spring Boot:Spring Boot 中 Redis 的使用

    Redis 介绍 Redis 是目前业界使用最广泛的内存数据存储.相比 Memcached,Redis 支持更丰富的数据结构,例如 hashes, lists, sets 等,同时支持数据持久化.除此 ...

  9. (转)Spring Boot(三):Spring Boot 中 Redis 的使用

    http://www.ityouknow.com/springboot/2016/03/06/spring-boot-redis.html Spring Boot 对常用的数据库支持外,对 Nosql ...

随机推荐

  1. 保存进程的pid 文件目录/var/run/

    http://blog.ddup.us/?p=110 http://blog.csdn.net/fyinsonw/article/details/4113124 首先声明这不是愚人节消息,事实上这个消 ...

  2. 安全控制 iptables

    转自:http://www.opsers.org/linux-home/videos/chapter-netfilter-iptables-raiders.html 内容简介防火墙的概述iptable ...

  3. 窗口生效函数UpdateData

    Invalidate()使整个窗口客户区无效.窗口的客户区无效意味着需要重绘,例如,如果一个被其它窗口遮住的窗口变成了前台窗口,那么原来被遮住的部分就是无效的,需要重绘.这时Windows会在应用程序 ...

  4. VMW虚拟机生成的文件说明

    VMDK(VMWare Virtual Machine Disk Format)是虚拟机VMware创建的虚拟硬格式,文件存在于VMware文件系统中,被称为VMFS(虚拟机文件系统) NVRAM 非 ...

  5. hdu 4678

    HDU 4768: Flyer 题意: 有N个社团,每个社团三个属性A,B,C,表示会向编号A+k*C的同学发传单(k=0,1,2...  && A+k*C <= B).题目保证 ...

  6. HDU 3342 Legal or Not(拓扑排序判断成环)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3342 题目大意:n个点,m条有向边,让你判断是否有环. 解题思路:裸题,用dfs版的拓扑排序直接套用即 ...

  7. dfs序题目练习

    参考博文:http://blog.csdn.net/qwe2434127/article/details/49819975 http://blog.csdn.net/qq_24489717/artic ...

  8. Codeforces Round #302 (Div. 1) B - Destroying Roads

    B - Destroying Roads 思路:这么菜的题我居然想了40分钟... n^2枚举两个交汇点,点与点之间肯定都跑最短路,取最小值. #include<bits/stdc++.h> ...

  9. bzoj 1833 数位dp

    很裸的数位dp. #include<bits/stdc++.h> #define LL long long #define fi first #define se second #defi ...

  10. Java中的强引用,软引用,弱引用

    作者:winterSunshine链接:https://www.zhihu.com/question/37401125/answer/100981172来源:知乎著作权归作者所有.商业转载请联系作者获 ...