当前位置:网站首页>狂神redis笔记10
狂神redis笔记10
2022-07-23 22:24:00 【抹茶味的西瓜汁】

我们新建一个咱们用来springboot和redis整合的一个模块:

然后我们依赖导完了,就开始去写我们的代码:

我们也要去先写我们的配置文件:

测试:
我们为了防止中文乱码啊等一些问题,我们也可以自己去创建redistemplate配置类:
创建是一个user实体类:
目前它还没有序列化。

![]()

运行测试一下:
![]()
可以正常测试。
我们现在不用json格式,直接用我们的类对象的形式:

可能会报错没有序列化,虽然我在写代码时候测试是没有报错的,所以我们可以给实体类加上序列化:
在我们的企业中很多pojo类都会实例化。
这段代码是固定的模板,我们以后可以拿来直接用。
我们可以使用这个注解去指定使用我们自己的redistemplate,而不是官方的。
我们用这种方式查找的key是单独字符串的形式,用官方的可能会出现乱码。
我们在企业中90%的几率都不会使用原生的方式去写redis命令,而是去使用自己创建的util工具类实现,所以我们可以自己去写一个:
这个我就不放在这里了,这个网上也有,狂神的视频里也有,直接拿来当模板用就可以了。
使用的时候先注入redisUtil。
然后我们在测试方法中去使用一下:
这个redisutil中也包含我们所有的redis的命令,可以拿来直接就使用。
测试结果:
Redis.conf详解:
我们默认的就是RDB,一般情况下不需要我们去修改。
然后我们去测试一下它:
我们先删除这个dump.rdb文件:
我们也能看出来我们默认的就是rdb。
当我们5条添加命令写完之后:

就会自动生成我们的rdb文件。
我们再删一次rdb文件:
我们进行flushall之后:

还是可以发现我们的这个文件的。

查看需要存放的位置:
如果这个目录下存在rdb文件,启动后就会默认恢复它的数据。
几乎就它自己的配置就够用了,但是我们还是会去学习。
有时候在生产环境我们会把这个rdb文件进行备份!

最后我们还是要把刚才改的配置恢复回默认的。
边栏推荐
- 138 - query case - knowledge points involved: foreach traversal & computed calculation attributes & V-for loop
- Application of performance test knowledge to actual combat
- [learning notes] diameter and center of gravity of the tree
- 思源笔记的字体比其他的编辑器(Atom,VSC,sublime)内字体渲染更细更淡
- Preliminary discussion on POC compilation
- DeFi项目的盈利逻辑 2021-04-26
- 接口测试
- Pulsar open source message queue_ Understand pulsar --- pulsar work notes 001
- synthesizable之Verilog可不可综合
- Yolo7 mask recognition practice
猜你喜欢

U++ learning notes control object scale

Matlab小波工具箱导入信号出错(doesn‘t contain one dimensional Singal)

【golang学习笔记】包(package)的使用

U++ events

zk 是如何解决脑裂问题的

达梦数据库tools包中的工具(操作达梦数据库)

Yuanqi Digitalization: existing mode or open source innovation Lixia action

Altium Designer - schematic diagram of Arduino uno & PCB diagram (self-made Arduino board)

人生总需要一点激情

为了一劳永逸而写的数独
随机推荐
Jmeter性能综合实战——签到及批量签到
Ali onedate's layered thought
What are the product life cycle, common project functions, and information flow
MySQL如何对SQL做prepare预处理(解决IN查询SQL预处理仅能查询出一条记录的问题)
The simple use of ADB command combined with monkey is super detailed
Real time monitoring of MySQL database changes_ Synchronize data_ Learn about canal_--- Canal work notes 001
Use of cjson Library
YOLO7 口罩识别实战
Preliminary discussion on POC compilation
Leetcode high frequency question 62. different paths: how many paths does the robot have from the upper left corner to the lower right corner? Pure probability permutation and combination problem, not
Array -- 209. Subarray with the smallest length
Apprentissage Lambda (utilisation du comparateur après tri, regroupement après collecte avec collectors.groupingby)
MySQL的JDBC编程
10 basic written interview questions, how many questions can you answer?
02. Supplement of knowledge related to web page structure
Cookies and sessions
JS - event proxy and application scenarios
Matlab wavelet toolbox import signal error (doesn't contain one dimensional single)
Programming in the novel [serial 18] the moon bends in the yuan universe
记忆化搜索 - DP