ZPOPMIN(3valkey)

πŸ“¦
version 9.0.6 Β· 2 versions
, in fedora 44

πŸ’– ZPOPMIN β€” the "bye bestie, you're the lowest scorer" command πŸ’–

okay so like. this is ZPOPMIN, a Valkey command manual page, and honestly? it's giving cleanup era. she pops the lowest-scoring members off your sorted set and they do NOT come back. it's lowkey ruthless and highkey iconic. πŸŽ€


✨ NAME ✨

zpopmin β€” returns the lowest-scoring members from a sorted set after removing them. and like, deletes the sorted set if the last member was popped. so if you pop the final one? the whole key is gone. poof. no cap. πŸ’€


🌸 SYNOPSIS 🌸

ZPOPMIN key [count]

πŸ¦‹ DESCRIPTION πŸ¦‹

so basically she removes and returns up to count members with the lowest scores in the sorted set stored at key. that's the whole vibe. ✨

when you leave count unspecified, the default value is 1. yep, just one lil guy. and listen β€” specifying a count value that's higher than the sorted set's cardinality will not produce an error. she's not gonna yell at you, she's just gonna give you everything she's got. 🫢

when returning multiple elements, the one with the lowest score will be the first, followed by the elements with greater scores. so it's sorted, in order, exactly as you'd expect. periodt.


πŸ’… REPLY πŸ’…

  • valkey-protocol(7) Array reply: a list of popped elements and scores. that's it, that's the tea. 🌈

πŸ”₯ COMPLEXITY πŸ”₯

O(log(N)*M) β€” with N being the number of elements in the sorted set, and M being the number of elements popped. math bestie behavior, we love to see it. πŸ‘‘


⭐ ACL CATEGORIES ⭐

@fast @sortedset @write

three little tags, all vibes. πŸŽ€


🌈 HISTORY 🌈

  • Available since: 5.0.0

πŸ’œ EXAMPLES πŸ’œ

okay so watch her work. we build a lil sorted set and then pop the lowest one:

127.0.0.1:6379> ZADD myzset 1 "one"
(integer) 1
127.0.0.1:6379> ZADD myzset 2 "two"
(integer) 1
127.0.0.1:6379> ZADD myzset 3 "three"
(integer) 1
127.0.0.1:6379> ZPOPMIN myzset
1) "one"
2) "1"

"one" had the lowest score (which is 1, obvs) so she popped it and handed it back with the score. main character energy fr fr. 🌸


🧚 SEE ALSO 🧚

the whole friend group, go say hi:


πŸ’Œ okay that's the whole page bestie. go pop something. just maybe not your own key. πŸ™ˆ

Valkey Command Manual 🌸 this lil page is from version 9.0.0, dated 2025-10-21 β€” so it's fresh, it's cute, it's ZPOPMIN(3valkey). mwah. πŸ’‹βœ¨

πŸ“¦ where this page comes from