diff --git a/apply/cache.go b/apply/cache.go new file mode 100644 index 0000000..9e5ec2b --- /dev/null +++ b/apply/cache.go @@ -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() +} diff --git a/option.go b/option.go new file mode 100644 index 0000000..d1ab5fd --- /dev/null +++ b/option.go @@ -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 // 实例标识 +}