package redis
import (
"context"
)
type ArrayCmdable interface {
ARSet (ctx context .Context , key string , index uint64 , values ...string ) *IntCmd
ARGet (ctx context .Context , key string , index uint64 ) *StringCmd
ARGetRange (ctx context .Context , key string , start, end uint64 ) *SliceCmd
ARMGet (ctx context .Context , key string , indexes ...uint64 ) *SliceCmd
ARMSet (ctx context .Context , key string , members ...AREntry ) *IntCmd
ARInsert (ctx context .Context , key string , values ...string ) *UintCmd
ARDel (ctx context .Context , key string , indexes ...uint64 ) *IntCmd
ARDelRange (ctx context .Context , key string , ranges ...ARRange ) *UintCmd
ARLen (ctx context .Context , key string ) *UintCmd
ARCount (ctx context .Context , key string ) *UintCmd
ARNext (ctx context .Context , key string ) *UintCmd
ARSeek (ctx context .Context , key string , index uint64 ) *IntCmd
ARInfo (ctx context .Context , key string ) *MapStringInterfaceCmd
ARInfoFull (ctx context .Context , key string ) *MapStringInterfaceCmd
ARScan (ctx context .Context , key string , start, end uint64 , args *ARScanArgs ) *AREntrySliceCmd
AROpSum (ctx context .Context , key string , start, end uint64 ) *StringCmd
AROpMin (ctx context .Context , key string , start, end uint64 ) *StringCmd
AROpMax (ctx context .Context , key string , start, end uint64 ) *StringCmd
AROpAnd (ctx context .Context , key string , start, end uint64 ) *IntCmd
AROpOr (ctx context .Context , key string , start, end uint64 ) *IntCmd
AROpXor (ctx context .Context , key string , start, end uint64 ) *IntCmd
AROpMatch (ctx context .Context , key string , start, end uint64 , value string ) *IntCmd
AROpUsed (ctx context .Context , key string , start, end uint64 ) *IntCmd
ARGrep (ctx context .Context , key string , start, end string , args *ARGrepArgs ) *UintSliceCmd
ARGrepWithValues (ctx context .Context , key string , start, end string , args *ARGrepArgs ) *AREntrySliceCmd
ARRing (ctx context .Context , key string , size uint64 , values ...string ) *UintCmd
ARLastItems (ctx context .Context , key string , count uint64 , rev bool ) *SliceCmd
}
type AREntry struct {
Index uint64
Value string
}
type ARRange struct {
Start uint64
End uint64
}
type ARScanArgs struct {
Limit uint64
}
type ARGrepPredicateType string
const (
ARGrepExact ARGrepPredicateType = "EXACT"
ARGrepMatch ARGrepPredicateType = "MATCH"
ARGrepGlob ARGrepPredicateType = "GLOB"
ARGrepRegex ARGrepPredicateType = "RE"
)
type ARGrepPredicate struct {
Type ARGrepPredicateType
Value string
}
type ARGrepArgs struct {
Predicates []ARGrepPredicate
CombineAnd bool
Limit uint64
NoCase bool
}
func (c cmdable ) ARSet (ctx context .Context , key string , index uint64 , values ...string ) *IntCmd {
args := make ([]any , 3 , 3 +len (values ))
args [0 ] = "arset"
args [1 ] = key
args [2 ] = index
for _ , v := range values {
args = append (args , v )
}
cmd := NewIntCmd (ctx , args ...)
_ = c (ctx , cmd )
return cmd
}
func (c cmdable ) ARGet (ctx context .Context , key string , index uint64 ) *StringCmd {
cmd := NewStringCmd (ctx , "arget" , key , index )
_ = c (ctx , cmd )
return cmd
}
func (c cmdable ) ARGetRange (ctx context .Context , key string , start , end uint64 ) *SliceCmd {
cmd := NewSliceCmd (ctx , "argetrange" , key , start , end )
_ = c (ctx , cmd )
return cmd
}
func (c cmdable ) ARMGet (ctx context .Context , key string , indexes ...uint64 ) *SliceCmd {
args := make ([]any , 2 +len (indexes ))
args [0 ] = "armget"
args [1 ] = key
for i , idx := range indexes {
args [2 +i ] = idx
}
cmd := NewSliceCmd (ctx , args ...)
_ = c (ctx , cmd )
return cmd
}
func (c cmdable ) ARMSet (ctx context .Context , key string , members ...AREntry ) *IntCmd {
args := make ([]any , 2 , 2 +2 *len (members ))
args [0 ] = "armset"
args [1 ] = key
for _ , m := range members {
args = append (args , m .Index , m .Value )
}
cmd := NewIntCmd (ctx , args ...)
_ = c (ctx , cmd )
return cmd
}
func (c cmdable ) ARInsert (ctx context .Context , key string , values ...string ) *UintCmd {
args := make ([]any , 2 , 2 +len (values ))
args [0 ] = "arinsert"
args [1 ] = key
for _ , v := range values {
args = append (args , v )
}
cmd := NewUintCmd (ctx , args ...)
_ = c (ctx , cmd )
return cmd
}
func (c cmdable ) ARDel (ctx context .Context , key string , indexes ...uint64 ) *IntCmd {
args := make ([]any , 2 +len (indexes ))
args [0 ] = "ardel"
args [1 ] = key
for i , idx := range indexes {
args [2 +i ] = idx
}
cmd := NewIntCmd (ctx , args ...)
_ = c (ctx , cmd )
return cmd
}
func (c cmdable ) ARDelRange (ctx context .Context , key string , ranges ...ARRange ) *UintCmd {
args := make ([]any , 2 , 2 +2 *len (ranges ))
args [0 ] = "ardelrange"
args [1 ] = key
for _ , r := range ranges {
args = append (args , r .Start , r .End )
}
cmd := NewUintCmd (ctx , args ...)
_ = c (ctx , cmd )
return cmd
}
func (c cmdable ) ARLen (ctx context .Context , key string ) *UintCmd {
cmd := NewUintCmd (ctx , "arlen" , key )
_ = c (ctx , cmd )
return cmd
}
func (c cmdable ) ARCount (ctx context .Context , key string ) *UintCmd {
cmd := NewUintCmd (ctx , "arcount" , key )
_ = c (ctx , cmd )
return cmd
}
func (c cmdable ) ARNext (ctx context .Context , key string ) *UintCmd {
cmd := NewUintCmd (ctx , "arnext" , key )
_ = c (ctx , cmd )
return cmd
}
func (c cmdable ) ARSeek (ctx context .Context , key string , index uint64 ) *IntCmd {
cmd := NewIntCmd (ctx , "arseek" , key , index )
_ = c (ctx , cmd )
return cmd
}
func (c cmdable ) ARInfo (ctx context .Context , key string ) *MapStringInterfaceCmd {
cmd := NewMapStringInterfaceCmd (ctx , "arinfo" , key )
_ = c (ctx , cmd )
return cmd
}
func (c cmdable ) ARInfoFull (ctx context .Context , key string ) *MapStringInterfaceCmd {
cmd := NewMapStringInterfaceCmd (ctx , "arinfo" , key , "full" )
_ = c (ctx , cmd )
return cmd
}
func (c cmdable ) ARScan (ctx context .Context , key string , start , end uint64 , scanArgs *ARScanArgs ) *AREntrySliceCmd {
args := make ([]any , 4 , 6 )
args [0 ], args [1 ], args [2 ], args [3 ] = "arscan" , key , start , end
if scanArgs != nil && scanArgs .Limit > 0 {
args = append (args , "limit" , scanArgs .Limit )
}
cmd := NewAREntrySliceCmd (ctx , args ...)
_ = c (ctx , cmd )
return cmd
}
func (c cmdable ) AROpSum (ctx context .Context , key string , start , end uint64 ) *StringCmd {
cmd := NewStringCmd (ctx , "arop" , key , start , end , "SUM" )
_ = c (ctx , cmd )
return cmd
}
func (c cmdable ) AROpMin (ctx context .Context , key string , start , end uint64 ) *StringCmd {
cmd := NewStringCmd (ctx , "arop" , key , start , end , "MIN" )
_ = c (ctx , cmd )
return cmd
}
func (c cmdable ) AROpMax (ctx context .Context , key string , start , end uint64 ) *StringCmd {
cmd := NewStringCmd (ctx , "arop" , key , start , end , "MAX" )
_ = c (ctx , cmd )
return cmd
}
func (c cmdable ) AROpAnd (ctx context .Context , key string , start , end uint64 ) *IntCmd {
cmd := NewIntCmd (ctx , "arop" , key , start , end , "AND" )
_ = c (ctx , cmd )
return cmd
}
func (c cmdable ) AROpOr (ctx context .Context , key string , start , end uint64 ) *IntCmd {
cmd := NewIntCmd (ctx , "arop" , key , start , end , "OR" )
_ = c (ctx , cmd )
return cmd
}
func (c cmdable ) AROpXor (ctx context .Context , key string , start , end uint64 ) *IntCmd {
cmd := NewIntCmd (ctx , "arop" , key , start , end , "XOR" )
_ = c (ctx , cmd )
return cmd
}
func (c cmdable ) AROpMatch (ctx context .Context , key string , start , end uint64 , value string ) *IntCmd {
cmd := NewIntCmd (ctx , "arop" , key , start , end , "MATCH" , value )
_ = c (ctx , cmd )
return cmd
}
func (c cmdable ) AROpUsed (ctx context .Context , key string , start , end uint64 ) *IntCmd {
cmd := NewIntCmd (ctx , "arop" , key , start , end , "USED" )
_ = c (ctx , cmd )
return cmd
}
func (c cmdable ) ARGrep (ctx context .Context , key string , start , end string , grepArgs *ARGrepArgs ) *UintSliceCmd {
args := make ([]any , 4 , 4 +grepArgs .Len ())
args [0 ], args [1 ], args [2 ], args [3 ] = "argrep" , key , start , end
args = grepArgs .Append (args )
cmd := NewUintSliceCmd (ctx , args ...)
_ = c (ctx , cmd )
return cmd
}
func (c cmdable ) ARGrepWithValues (ctx context .Context , key string , start , end string , grepArgs *ARGrepArgs ) *AREntrySliceCmd {
args := make ([]any , 4 , 5 +grepArgs .Len ())
args [0 ], args [1 ], args [2 ], args [3 ] = "argrep" , key , start , end
args = grepArgs .Append (args )
args = append (args , "withvalues" )
cmd := NewAREntrySliceCmd (ctx , args ...)
_ = c (ctx , cmd )
return cmd
}
func (args *ARGrepArgs ) Len () int {
if args == nil {
return 0
}
n := 2 * len (args .Predicates )
if args .CombineAnd {
n ++
}
if args .Limit > 0 {
n += 2
}
if args .NoCase {
n ++
}
return n
}
func (args *ARGrepArgs ) Append (a []any ) []any {
if args == nil {
return a
}
for _ , p := range args .Predicates {
a = append (a , string (p .Type ), p .Value )
}
if args .CombineAnd {
a = append (a , "and" )
}
if args .Limit > 0 {
a = append (a , "limit" , args .Limit )
}
if args .NoCase {
a = append (a , "nocase" )
}
return a
}
func (c cmdable ) ARRing (ctx context .Context , key string , size uint64 , values ...string ) *UintCmd {
args := make ([]any , 3 , 3 +len (values ))
args [0 ] = "arring"
args [1 ] = key
args [2 ] = size
for _ , v := range values {
args = append (args , v )
}
cmd := NewUintCmd (ctx , args ...)
_ = c (ctx , cmd )
return cmd
}
func (c cmdable ) ARLastItems (ctx context .Context , key string , count uint64 , rev bool ) *SliceCmd {
args := make ([]any , 3 , 4 )
args [0 ], args [1 ], args [2 ] = "arlastitems" , key , count
if rev {
args = append (args , "rev" )
}
cmd := NewSliceCmd (ctx , args ...)
_ = c (ctx , cmd )
return cmd
}
The pages are generated with Golds v0.8.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .