Skip to content

Commit

Permalink
feat(redis): implement interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Matrix-X committed Dec 2, 2021
1 parent 6ff2ea1 commit 9807e8e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion cache/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ func (gr *GRedis) Add(key string, value interface{}, ttl time.Duration) (err err

}

func (gr *GRedis) Set(key string, value interface{}, expires time.Duration) error {
result := gr.Pool.Set(CTXRedis, key, value, expires)
return result.Err()
}

func (gr *GRedis) SetEx(key string, value interface{}, expires time.Duration) error {
mValue, err := json.Marshal(value)
//mExpire, err := json.Marshal(expires)
Expand Down Expand Up @@ -191,6 +196,15 @@ func (gr *GRedis) Get(key string, ptrValue interface{}) (returnValue interface{}
return returnValue, err
}

func (gr *GRedis) Has(key string) bool {

value, err := gr.Get(key, nil)
if value != nil && err == nil {
return true
}

return false
}

func (gr *GRedis) GetMulti(keys ...string) (object.HashMap, error) {
res, err := gr.Pool.MGet(CTXRedis, keys...).Result()
Expand Down Expand Up @@ -254,7 +268,6 @@ func (gr *GRedis) Remember(key string, ttl time.Duration, callback func() interf
return value, err
}


/**
* Store an item in the cache.
*
Expand Down

0 comments on commit 9807e8e

Please sign in to comment.