2

I made a script that is used to update many clients. The script should be able to be ran in multiple instances.

At first Redis will retrieve all client's IDs. Then, each instances of the script will RPOPLPUSH-ing all the clients (update a client and put in the back of the list).

The script should be able to detect if new client is registered (querying to database) and need to have its ID to be put into the list/set. Hence, I need to have the set to be unique, no repeating ID.

Sorted set seems to be the solution here, but it does not have RPOPLPUSH functionality. What are my options?

notalentgeek
  • 4,939
  • 11
  • 34
  • 53

1 Answers1

0

Go with Sorted Sets, but implement your own variant of the requested command with a simple Redis server-side Lua script (EVAL).

Sorted Sets are always ordered by score (and then, in case of identical scores, lexicographically by element). It is unclear from the question where you'll be "popping" from (highest? lowest?) and where you'll be pushing to, but as you know your requirements you probably know best :)

Itamar Haber
  • 47,336
  • 7
  • 91
  • 117