optimized_go_tools/am_docs/redis.md
2024-07-08 11:14:19 +08:00

39 lines
740 B
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Redis 工具包
集成了Redis配置、set和get。
## 使用方法
> Attention⚠如果需要使用JWT套件请务必配置Redis因为该套件依赖Redis执行。
### 配置Redis
```go
// 使用默认配置 127.0.0.1:6379 password="" DB=0
am_redis.Setup(nil)
// 使用自定义配置
var redisConn = am_redis.RedisConn{
Addr: "localhost",
Port: "6379",
Password: "",
DB: 0,
}
am_redis.Setup(&redisConn)
```
### 存入Redis
```go
// 参数1: key
// 参数2: value
// 参数3: 过期时间以s为计数单位。0表示永不过期
am_redis.SetValue("key", "value", 0)
```
### 从Redis取出
```go
// 参数1: key
am_redis.GetValue("key")
```
### 从Redis中删除
```go
// 参数1: key
am_redis.DelValue("key")
```