save code

This commit is contained in:
白茶清欢 2023-03-09 10:31:14 +08:00
parent 72add1ba6a
commit 0a83c18e4f
2 changed files with 55 additions and 0 deletions

37
apply/cache.go Normal file
View File

@ -0,0 +1,37 @@
// Package apply ...
//
// Description : apply ...
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 2023-02-13 11:24
package apply
import (
"git.zhangdeman.cn/zhangdeman/redis"
)
var (
// Cache 数据缓存的场景
Cache *cache
)
type cache struct {
}
// Set 设置缓存
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 11:28 2023/2/13
func (c *cache) Set(ctx *redis.Context, key string, value interface{}) error {
var (
err error
rc *redis.RealClient
)
if rc, err = redis.Client.GetRedisClient(ctx.Flag); nil != err {
return err
}
return rc.Master.Set(nil, key, value, -1).Err()
}

18
option.go Normal file
View File

@ -0,0 +1,18 @@
// Package redis ...
//
// Description : redis ...
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 2023-02-13 14:29
package redis
// Option 使用redis时的可选信息
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 14:30 2023/2/13
type Option struct {
ForceMaster bool // 强制操作主库, 写操作默认主库, 读操作不指定默认从库
Flag string // 实例标识
}