MCPcopy Create free account
hub / github.com/dbProjectRED/redimo.go / zPop

Method zPop

sorted_sets.go:241–261  ·  view source on GitHub ↗
(key string, count int64, forward bool)

Source from the content-addressed store, hash-verified

239var posInf = zScore{math.Inf(+1)}
240
241func (c Client) zPop(key string, count int64, forward bool) (membersWithScores map[string]float64, err error) {
242 membersWithScores, err = c.zGeneralRange(key, negInf, posInf, 0, count, forward, c.skN)
243 if err != nil {
244 return
245 }
246
247 poppedMembers := make(map[string]float64)
248
249 for member, score := range membersWithScores {
250 popped, err := c.ZREM(key, member)
251 if err != nil {
252 return poppedMembers, err
253 }
254
255 if len(popped) > 0 {
256 poppedMembers[member] = score
257 }
258 }
259
260 return poppedMembers, err
261}
262
263func (c Client) ZRANGE(key string, start, stop int64) (membersWithScores map[string]float64, err error) {
264 return c.zRange(key, start, stop, true)

Callers 2

ZPOPMAXMethod · 0.95
ZPOPMINMethod · 0.95

Calls 2

zGeneralRangeMethod · 0.95
ZREMMethod · 0.95

Tested by

no test coverage detected