github.com/wangyougui/gf/v2@v2.6.5/database/gredis/gredis_redis_group_string.go (about) 1 // Copyright GoFrame Author(https://goframe.org). All Rights Reserved. 2 // 3 // This Source Code Form is subject to the terms of the MIT License. 4 // If a copy of the MIT was not distributed with this file, 5 // You can obtain one at https://github.com/wangyougui/gf. 6 7 package gredis 8 9 import ( 10 "context" 11 12 "github.com/wangyougui/gf/v2/container/gvar" 13 ) 14 15 // IGroupString manages redis string operations. 16 // Implements see redis.GroupString. 17 type IGroupString interface { 18 Set(ctx context.Context, key string, value interface{}, option ...SetOption) (*gvar.Var, error) 19 SetNX(ctx context.Context, key string, value interface{}) (bool, error) 20 SetEX(ctx context.Context, key string, value interface{}, ttlInSeconds int64) error 21 Get(ctx context.Context, key string) (*gvar.Var, error) 22 GetDel(ctx context.Context, key string) (*gvar.Var, error) 23 GetEX(ctx context.Context, key string, option ...GetEXOption) (*gvar.Var, error) 24 GetSet(ctx context.Context, key string, value interface{}) (*gvar.Var, error) 25 StrLen(ctx context.Context, key string) (int64, error) 26 Append(ctx context.Context, key string, value string) (int64, error) 27 SetRange(ctx context.Context, key string, offset int64, value string) (int64, error) 28 GetRange(ctx context.Context, key string, start, end int64) (string, error) 29 Incr(ctx context.Context, key string) (int64, error) 30 IncrBy(ctx context.Context, key string, increment int64) (int64, error) 31 IncrByFloat(ctx context.Context, key string, increment float64) (float64, error) 32 Decr(ctx context.Context, key string) (int64, error) 33 DecrBy(ctx context.Context, key string, decrement int64) (int64, error) 34 MSet(ctx context.Context, keyValueMap map[string]interface{}) error 35 MSetNX(ctx context.Context, keyValueMap map[string]interface{}) (bool, error) 36 MGet(ctx context.Context, keys ...string) (map[string]*gvar.Var, error) 37 } 38 39 // TTLOption provides extra option for TTL related functions. 40 type TTLOption struct { 41 EX *int64 // EX seconds -- Set the specified expire time, in seconds. 42 PX *int64 // PX milliseconds -- Set the specified expire time, in milliseconds. 43 EXAT *int64 // EXAT timestamp-seconds -- Set the specified Unix time at which the key will expire, in seconds. 44 PXAT *int64 // PXAT timestamp-milliseconds -- Set the specified Unix time at which the key will expire, in milliseconds. 45 KeepTTL bool // Retain the time to live associated with the key. 46 } 47 48 // SetOption provides extra option for Set function. 49 type SetOption struct { 50 TTLOption 51 NX bool // Only set the key if it does not already exist. 52 XX bool // Only set the key if it already exists. 53 54 // Return the old string stored at key, or nil if key did not exist. 55 // An error is returned and SET aborted if the value stored at key is not a string. 56 Get bool 57 } 58 59 // GetEXOption provides extra option for GetEx function. 60 type GetEXOption struct { 61 TTLOption 62 Persist bool // Persist -- Remove the time to live associated with the key. 63 }