feat: upgrade cache
This commit is contained in:
@ -51,7 +51,7 @@ func (g *Gocache) TTL(ctx context.Context, cacheInstanceFlag string, key string)
|
||||
return expireAt.Unix() - time.Now().Unix(), nil
|
||||
}
|
||||
|
||||
func (g *Gocache) Set(ctx context.Context, cacheInstanceFlag string, key string, value string, ttl int64) error {
|
||||
func (g *Gocache) Set(ctx context.Context, cacheInstanceFlag string, key string, value any, ttl int64) error {
|
||||
now := time.Now()
|
||||
if now.Unix() < ttl {
|
||||
ttl = ttl - now.Unix()
|
||||
@ -60,7 +60,7 @@ func (g *Gocache) Set(ctx context.Context, cacheInstanceFlag string, key string,
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *Gocache) Get(ctx context.Context, cacheInstanceFlag string, key string) (string, error) {
|
||||
func (g *Gocache) Get(ctx context.Context, cacheInstanceFlag string, key string) (any, error) {
|
||||
val, exist := GocacheStorageClient.Get(cacheInstanceFlag).Get(key)
|
||||
if !exist {
|
||||
return "", errors.New(key + " : not found")
|
||||
@ -68,7 +68,7 @@ func (g *Gocache) Get(ctx context.Context, cacheInstanceFlag string, key string)
|
||||
return val.(string), nil
|
||||
}
|
||||
|
||||
func (g *Gocache) GetWithParse(ctx context.Context, cacheInstanceFlag string, key string, parseFunc cacheAbstract.ResultParseFunc) (string, error) {
|
||||
func (g *Gocache) GetWithParse(ctx context.Context, cacheInstanceFlag string, key string, parseFunc cacheAbstract.ResultParseFunc) (any, error) {
|
||||
val, err := g.Get(ctx, cacheInstanceFlag, key)
|
||||
if nil != err {
|
||||
return "", err
|
||||
|
Reference in New Issue
Block a user