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

Function cmdLINDEX

lists.go:378–398  ·  view source on GitHub ↗
(m uhaha.Machine, args []string)

Source from the content-addressed store, hash-verified

376 if err != nil {
377 return nil, err
378 }
379
380 return redcon.SimpleInt(n), nil
381}
382
383func cmdLINDEX(m uhaha.Machine, args []string) (interface{}, error) {
384 if len(args) != 3 {
385 return nil, uhaha.ErrWrongNumArgs
386 }
387 index, err := ledis.StrInt64([]byte(args[2]), nil)
388 if err != nil {
389 return nil, err
390 }
391
392 v, err := ldb.LIndex([]byte(args[1]), int32(index))
393 if err != nil {
394 return nil, err
395 }
396
397 // return `(nil)` when out of range
398 if len(v) == 0 {
399 return nil, nil
400 }
401

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected