forked from p93542168/wheat-cache
feat(proto): add new key base
This commit is contained in:
parent
bed3f1893a
commit
3bcd154177
|
@ -1,5 +1,9 @@
|
|||
package proto
|
||||
|
||||
import (
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
)
|
||||
|
||||
type GetKeyBaseInterface interface {
|
||||
GetKey() *BaseKey
|
||||
}
|
||||
|
@ -7,3 +11,25 @@ type GetKeyBaseInterface interface {
|
|||
const (
|
||||
BaseKeyMethodKey = "basekey"
|
||||
)
|
||||
|
||||
// NewBaseKey
|
||||
// key,ttl,expire
|
||||
func NewBaseKey(key string, t ...int64) *BaseKey {
|
||||
var expire *timestamppb.Timestamp
|
||||
var ttl int64
|
||||
|
||||
if len(t) > 1 {
|
||||
expire = ×tamppb.Timestamp{
|
||||
Seconds: t[1],
|
||||
}
|
||||
ttl = t[0]
|
||||
} else if len(t) == 1 {
|
||||
ttl = t[0]
|
||||
}
|
||||
|
||||
return &BaseKey{
|
||||
Key: key,
|
||||
Expire: expire,
|
||||
Ttl: ttl,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue