Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimized Lua script for Redis >= 6.2.0 #50

Merged
merged 3 commits into from
Nov 29, 2022

Conversation

russointroitoa
Copy link
Contributor

The previous version of PLUCK_SCRIPT used the following Redis commands:
LRANGE --> Complexity: O(S+N) where S: the distance of start offset from HEAD and N: number of elements in the specified range
LTRIM --> Complexity: O(N)
SREM * N times --> Complexity: O(1) * N = O(N)

Number of commands used: 1 [ LRANGE ] + 1 [ LTRIM ] + N * 1 [ SREM ] = N + 2

Instead, the current version uses the following:
LPOP with count parameter --> Complexity: O(N)
SREM with list of keys --> Complexity: O(N)

Number of commands used: 1 [ LPOP ] + 1 [ SREM ]= 2

@gzigzigzeo gzigzigzeo merged commit 38562c2 into gzigzigzeo:master Nov 29, 2022
@russointroitoa russointroitoa deleted the improve_lua_script branch November 29, 2022 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants