You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
508 B

package cache
import (
"fmt"
"github.com/go-redis/redis"
"recook/internal/dbc"
"recook/internal/model/store"
"time"
)
func SetStoreLoginCache(u *store.Account) {
k := fmt.Sprintf("store_%d", u.ID)
err := dbc.Rds.Set(k, u.Token, time.Hour*12).Err()
if err != nil {
panic(err)
}
}
func GetStoreLoginCache(id uint) string {
k := fmt.Sprintf("store_%d", id)
val, err := dbc.Rds.Get(k).Result()
if err != nil {
if err == redis.Nil {
return ""
} else {
panic(err)
}
}
return val
}