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

Method cmdEXISTS

IceFireDB-PubSub/pkg/router/redisCluster/strings.go:84–115  ·  view source on GitHub ↗
(s *router.Context)

Source from the content-addressed store, hash-verified

82}
83
84func (r *Router) cmdEXISTS(s *router.Context) error {
85 argLen := len(s.Args)
86
87 if argLen == 2 {
88 reply, err := rediscluster.Int64(r.redisCluster.Do(s.Cmd, s.Args[1]))
89 if err != nil {
90 return router.WriteError(s.Writer, err)
91 }
92 return router.WriteInt(s.Writer, reply)
93 }
94
95 batch := r.redisCluster.NewBatch()
96 for i := 1; i < argLen; i++ {
97 err := batch.Put(s.Cmd, s.Args[i])
98 if err != nil {
99 return err
100 }
101 }
102 reply, err := rediscluster.Values(r.redisCluster.RunBatch(batch))
103 if err != nil && err != rediscluster.ErrNil {
104 return router.WriteError(s.Writer, err)
105 }
106
107 var existsCount int64
108 for _, valInterface := range reply {
109 if count, ok := valInterface.(int64); ok {
110 existsCount += count
111 }
112 }
113 s.Reply = existsCount
114 return router.WriteInt(s.Writer, existsCount)
115}

Callers

nothing calls this directly

Calls 4

WriteErrorFunction · 0.92
WriteIntFunction · 0.92
DoMethod · 0.45
PutMethod · 0.45

Tested by

no test coverage detected