赞
踩
链接:百度网盘 请输入提取码 提取码:0410
一个名对应一个数值
内存级 在内存里进行操作
我们现在就有一个redis客户端的服务器了
我们再启动一个cmd
redis里面的基本数据类型有五种
还有其他的拓展数据类型
要操作redis服务器
得告诉他
所以我们要对redis进行配置
我们在yml配置文件里进行配置
- spring:
- redis:
- host: localhost
- port: 6379
RedisTemplate
是 Spring Framework 提供的用于操作 Redis 数据库的核心类之一。它是 Spring Data Redis 模块的一部分,通过提供高级的、线程安全的访问 Redis 数据库的方法,简化了与 Redis 的集成和操作。
- package com.bigdata1421.redis;
-
- import org.junit.jupiter.api.Test;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.boot.test.context.SpringBootTest;
- import org.springframework.data.redis.core.RedisTemplate;
- import org.springframework.data.redis.core.ValueOperations;
-
- @SpringBootTest
- class RedisApplicationTests {
-
- @Autowired
- private RedisTemplate redisTemplate;
-
- @Test
- void test() {
- //SET 操作
- ValueOperations ops1=redisTemplate.opsForValue();
- ops1.set("age",21);
-
-
- //GET 操作
- ValueOperations ops2=redisTemplate.opsForValue();
- Object age=ops2.get("age");
- System.out.println(age);
- }
-
- }

还可以放哈希格式的数据
其实springboot整合redis就是
主要靠一个RedisTemplate
我们发现在idea里使用的redis
即在springboot里整合的redis
和我们之前安装的redis不是一个redis
即我们在springboot里往redis里传入写入字段数据
我们在控制台
在命令行cmd窗口查询查不到
我们把cmd停掉
发现不能运行
我们写在数据库里面的是以字符串为数据类型的存储单元
我们传入的数据
如果是对象类型
用命令行去查询时得会转码
就是指定格式
在把数据写入数据库的时候 已经把对象类型的数据进行了转码
这样我们就能放入我们之前存入的数据
其实我们制定泛型也行
而不是默认Object存入
- <dependency>
- <groupId>redis.clients</groupId>
- <artifactId>jedis</artifactId>
- <version>5.1.2</version>
- </dependency>
如连接池最大活动连接数
- spring:
- redis:
- host: localhost
- port: 6379
- client-type: jedis
- spring:
- redis:
- host: localhost
- port: 6379
- client-type: jedis
-
- jedis:
- pool:
- max-active: 8
博客主页
Web后端开发
https://blog.csdn.net/qq_30500575/category_12624592.html?spm=1001.2014.3001.5482
Web前端开发
https://blog.csdn.net/qq_30500575/category_12642989.html?spm=1001.2014.3001.5482
数据库开发
https://blog.csdn.net/qq_30500575/category_12651993.html?spm=1001.2014.3001.5482
项目实战
https://blog.csdn.net/qq_30500575/category_12699801.html?spm=1001.2014.3001.5482
算法与数据结构
https://blog.csdn.net/qq_30500575/category_12630954.html?spm=1001.2014.3001.5482
计算机基础
https://blog.csdn.net/qq_30500575/category_12701605.html?spm=1001.2014.3001.5482
回忆录
https://blog.csdn.net/qq_30500575/category_12620276.html?spm=1001.2014.3001.5482
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。