diff --git a/const.go b/const.go index 1c08ba8..0fc47f2 100644 --- a/const.go +++ b/const.go @@ -1,3 +1,3 @@ package dorm -const Version = "1.0.17" +const Version = "1.0.18" diff --git a/redis_cache.go b/redis_cache.go index 6fe6630..2213cd0 100644 --- a/redis_cache.go +++ b/redis_cache.go @@ -71,3 +71,19 @@ func (rc *RedisClientCache) GetInterface(ctx context.Context, key string, result return } + +// GetInterfaceKey 获取key值 +func (rc *RedisClientCache) GetInterfaceKey(ctx context.Context, key string, result interface{}) error { + ret, err := rc.operation.Get(ctx, key).Result() + if err != nil { + return err + } + err = json.Unmarshal([]byte(ret), result) + return nil +} + +// SetInterfaceKey 设置key值 +func (rc *RedisClientCache) SetInterfaceKey(ctx context.Context, key string, value interface{}) (string, error) { + marshal, _ := json.Marshal(value) + return rc.operation.Set(ctx, key, marshal, rc.config.DefaultExpiration).Result() +}