Documentation ¶
Overview ¶
Package redcas realizes CAS extension function.
Index ¶
- Constants
- Variables
- func BytesToString(b []byte) string
- func Decode(raw []byte) ([]byte, int64, error)
- func Encode(value []byte, cas int64) []byte
- func Marshal(in interface{}) ([]byte, error)
- func MarshalJSONString(v interface{}) string
- func NextCAS(cas int64) int64
- func StringToBytes(s string) []byte
- func Unmarshal(in []byte, message interface{}) error
- type GetCmd
- type HSetCmd
- type MGetCmd
- type MSetCmd
- type S
- type SetCmd
Constants ¶
const ( ForceSetCAS = -1 // Mandatory modification cas. MaxCAS = math.MaxInt32 // Lua only supports float64, )
const ( // SetLua set lua script. SetLua = `` /* 656-byte string literal not displayed */ // HSetLua lua script. HSetLua = `` /* 454-byte string literal not displayed */ // MSetLua MSet lua script. MSetLua = `` /* 605-byte string literal not displayed */ // HMSetLua HMSet lua script. HMSetLua = `` /* 755-byte string literal not displayed */ )
lua script.
Variables ¶
var ( // SetScript is set script optimizer. // Execute and upload the script through Eval if the server does not exist, // and execute it through EvalSha if it exists. SetScript = script.New(SetLua) // HSetScript HSet script optimization. // Execute and upload the script through Eval if the server does not exist, // and execute it through EvalSha if it exists. HSetScript = script.New(HSetLua) // MSetScript MSet script optimization. // Execute and upload the script through Eval if the server does not exist, // and execute it through EvalSha if it exists. MSetScript = script.New(MSetLua) // HMSetScript HMSet script optimization. // Execute and upload the script through Eval if the server does not exist, // and execute it through EvalSha if it exists. HMSetScript = script.New(HMSetLua) )
Functions ¶
func BytesToString ¶
BytesToString converts byte slice to string.
func MarshalJSONString ¶
func MarshalJSONString(v interface{}) string
MarshalJSONString is convenient for printing logs.
func StringToBytes ¶
StringToBytes converts string to byte slice.
Types ¶
type GetCmd ¶
GetCmd get command.
type HSetCmd ¶
HSetCmd HSet is result class.
type MGetCmd ¶
MGetCmd MGet is result class.
type MSetCmd ¶
MSetCmd is mset result parser.
func HMSet ¶
HMSet is redis set function, cas function description: ForceSetCAS(-1) force modification, 0 means set if it does not exist, duration 0 means no expiration time.
func MSet ¶
MSet redis, MSet functions are implemented through pipelines, compatible with all versions of redis, it is recommended to use the cluster version. Lua script version reference MSetWithEval.
func MSetWithEval ¶
MSetWithEval redis MSet lua script version, strong performance, not compatible with the cluster version key across slots, etc., it is recommended to use the redis standard version. Key cross-slot can also be adjusted by adding hash tags, specifically: http://www.redis.cn/commands/cluster-keyslot.html,
type S ¶
type S struct { Key string // MSet is the key field, HMSet is the field. Value interface{} // Setting value. CAS int64 // cas ForceSetCAS(-1) mandatory modification, 0 means set if it does not exist. Duration time.Duration // Validity period, only valid for MSetWithPipelined. }
S is Set/HSet value structure.
type SetCmd ¶
SetCmd is set result parser.
func Set ¶
func Set(ctx context.Context, c redis.Cmdable, key string, value interface{}, cas int64, duration time.Duration) *SetCmd
Set redis set function, cas function description: ForceSetCAS(-1) force modification, 0 means set if it does not exist, duration 0 means no expiration time. EvalSha has compatibility: when executing the SCRIPT LOAD command on a single node, it is not guaranteed to save the Lua script to other nodes, See:https://help.aliyun.com/document_detail/92942.html#section-8f7-qgv-dlv