一、市面上常见的NoSQL解决方案(下面的技术通常在Linux系统中安装部署)
-
Redis
-
Mongo
-
ES
二、Redis
Redis是一款key-value存储结构的内存级NoSQL数据库
支持多种数据存储格式
支持持久化
支持集群
下载与安装 (我安的是window版本)
链接:网盘下载地址
提取码:yyqx
windows解压安装或一键式安装
服务端启动命令
redis-server.exe redis.windows.conf
客户端启动命令
redis-cli.exe
三、SpringBoot整合Redis
1、新建Springboot工程,选择nosql中的第一个Redis(就是加了下面的坐标)
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
2、配置文件
3、测试类中进行测试
package com.example;
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 SpringBoot09RedisApplicationTests {
@Autowired
private RedisTemplate redisTemplate;
@Test
void set() {
ValueOperations ops = redisTemplate.opsForValue();
ops.set("age",18);
}
@Test
void get(){
ValueOperations ops= redisTemplate.opsForValue();
Object age=ops.get("age");
System.out.println(age);
}
}
四、客户端选择jedis
1、添加坐标
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>