2021-10-17 10:49:14 +08:00
|
|
|
|
package proto
|
|
|
|
|
|
2021-11-01 15:28:52 +08:00
|
|
|
|
import (
|
|
|
|
|
"google.golang.org/protobuf/types/known/timestamppb"
|
|
|
|
|
)
|
|
|
|
|
|
2021-10-17 10:49:14 +08:00
|
|
|
|
type GetKeyBaseInterface interface {
|
|
|
|
|
GetKey() *BaseKey
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const (
|
2021-10-17 19:27:00 +08:00
|
|
|
|
BaseKeyMethodKey = "basekey"
|
2021-10-17 10:49:14 +08:00
|
|
|
|
)
|
2021-11-01 15:28:52 +08:00
|
|
|
|
|
|
|
|
|
// NewBaseKey
|
|
|
|
|
// key,ttl,expire
|
|
|
|
|
func NewBaseKey(key string, t ...int64) *BaseKey {
|
2021-11-03 15:36:55 +08:00
|
|
|
|
var expire *timestamppb.Timestamp = nil
|
2021-11-01 15:28:52 +08:00
|
|
|
|
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,
|
|
|
|
|
}
|
|
|
|
|
}
|