# redis
# maven引入
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
# 配置
# 以下配置根据实际情况修改
spring:
redis:
host: localhost
port: 6379
database: 0
timeout: 5000
password: 123456
jedis:
pool:
max-active: 100
max-idle: 10
max-wait: 10000
min-idle: 0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
# 使用
import redis; //导入redis模块
var value = 'hello';
//通过redis.命令名(命令参数,命令参数,.....,命令参数) 进行调用,其中命令名不区分大小写
redis.set('key',value); //调用set命令
redis.setex('key',10,value); //调用setex命令
return redis.get('key'); //调用get命令
1
2
3
4
5
6
2
3
4
5
6