MCPcopy Create free account
hub / github.com/IceFireDB/IceFireDB / cmdZADD

Function cmdZADD

sorted_sets.go:292–315  ·  view source on GitHub ↗
(m uhaha.Machine, args []string)

Source from the content-addressed store, hash-verified

290}
291
292func cmdZADD(m uhaha.Machine, args []string) (interface{}, error) {
293 if len(args) < 3 {
294 return nil, uhaha.ErrWrongNumArgs
295 }
296
297 ScorePair := make([]ledis.ScorePair, (len(args)-2)/2)
298
299 index := 0
300 for i := 2; i < len(args); i += 2 {
301 if score, err := strconv.Atoi(string(args[i])); err == nil {
302 ScorePair[index].Score = int64(score)
303 ScorePair[index].Member = []byte(args[i+1])
304 index++
305 }
306 }
307
308 n, err := ldb.ZAdd([]byte(args[1]), ScorePair...)
309
310 if err != nil {
311 return nil, err
312 }
313
314 return redcon.SimpleInt(n), nil
315}
316
317func cmdZSCORE(m uhaha.Machine, args []string) (interface{}, error) {
318 if len(args) != 3 {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected