Quantcast
Channel: Active questions tagged redis+ruby-on-rails - Stack Overflow
Viewing all articles
Browse latest Browse all 873

Delete a key from all the cursors in redis

$
0
0

This is the way I have added the alert in redis. Now the problem is when we use zadd it automatically adds at any random cursors. What I want to achieve is to delete a specific key from all the cursors. The problem is I am not sure how many cursors there are and how I can iterate on all the cursors to delete the specific key.

redis_key = "component_list"user_alert = "#{user_id}:#{friend_id}:#{user_code}"redis.zadd(redis_key, ::Time.current.to_i, user_alert)match_key = "abc_code"alerts_arr = redis.zscan(redis_key, 0, match: "*#{match_key}*").last.map(&:first)alerts_arr.each { |alert| redis.zrem(REDIS_KEY, alert) }

From the above code, it only deletes from the 0th cursors. But I want to delete it from all the cursors. Can someone help me with it?


Viewing all articles
Browse latest Browse all 873

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>