package myRedis import ( "fmt" "time" ) const ( AttrExpr = "expr" AttrNx = "nx" AttrXx = "xx" ) type empty struct { } type OperationAttr struct { Name string Value interface{} } type OperationAttrs []*OperationAttr func (t OperationAttrs) Find(name string) *InterfaceResult { for _, attr := range t { if attr.Name == name { return NewInterfaceResult(attr.Value, nil) } } return NewInterfaceResult(nil, fmt.Errorf("OperationAttrs found error:%s", name)) } func WithExpire(t time.Duration) *OperationAttr { return &OperationAttr{ Name: AttrExpr, Value: t, } } func WithNX() *OperationAttr { return &OperationAttr{ Name: AttrNx, Value: empty{}, } } func WithXX() *OperationAttr { return &OperationAttr{ Name: AttrXx, Value: empty{}, } }