Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello Antirez/Salvatore,
I have made a modification to the rpoplpush command, in the modification i am allowing a third optional parameters which will provide the following behavior:
allow as an option a third argument which would be pushed as new element
on the destination list instead of pushing the popped element.
RPOPLPUSH srclist dstlist element2:
IF LLEN(srclist) > 0
element = RPOP srclist
LPUSH dstlist element2
RETURN element
ELSE
RETURN nil
END
END
This is very useful in my opinion to provide a way to atomically remove an element from a list and pass a new one to another list.
Let me provide an example.
Script A receive an element to be processed on list_A.
Script a uses the traditional rpoplpush this way element = rpoplpush list_A list_A_processing.
The script is processing element, and modifying it.
Once the modification is done we need to atomically remove the element from list_A_processing and pass the modified element to another list so that script B can process the newly modified element.
So script will use the modified way of rpoplpush this way. rpoplpush list_A_processing list_B newelement
This is the only way in my understanding to pass the element to the other script (using redis of course) and at the same time remove it from the processing list without risking to break the atomicity of this action.
Imagine the script is killed in the middle of this operation (pop and then push, or push and then pop) we would have an issue of integrity.
I know this will affect brpoplpush but I think it will also be beneficial to it.
By the way I am not an expert in git/github so i dont know how to remove from this pull request the other pull request i have made regarding the list command.
Thanks in advance,
Kader
Python Example: