feat: use cache to avoid database access (#158)

This commit is contained in:
JustSong
2023-06-20 19:09:49 +08:00
parent 4250064296
commit 3d76a974d1
5 changed files with 123 additions and 4 deletions

View File

@@ -37,3 +37,18 @@ func ParseRedisOption() *redis.Options {
}
return opt
}
func RedisSet(key string, value string, expiration time.Duration) error {
ctx := context.Background()
return RDB.Set(ctx, key, value, expiration).Err()
}
func RedisGet(key string) (string, error) {
ctx := context.Background()
return RDB.Get(ctx, key).Result()
}
func RedisDel(key string) error {
ctx := context.Background()
return RDB.Del(ctx, key).Err()
}