Ai
1 Star 0 Fork 0

masaichi/工具包

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
OperationAttr.go 582 Bytes
一键复制 编辑 原始数据 按行查看 历史
邓正锋 提交于 2024-05-17 16:02 +08:00 . 添加redis操作方法
package goredis
import (
"fmt"
"time"
)
const ATTR_EXPIRE = "expire"
type OperationAttr struct {
Name string
Value interface{}
}
type OperationAttrs []*OperationAttr
// 查找是否有该属性
func (this OperationAttrs) Find(name string) *InterfaceResult {
for _, attr := range this {
if attr.Name == name {
return NewInterfaceResult(attr.Value, nil)
}
}
return NewInterfaceResult(nil, fmt.Errorf("operation found error %s", name))
}
// 设置过期时间
func WithExpire(t time.Duration) *OperationAttr {
return &OperationAttr{Name: ATTR_EXPIRE, Value: t}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/masaichi/mastool.git
git@gitee.com:masaichi/mastool.git
masaichi
mastool
工具包
v0.0.4

搜索帮助