RedisLockRegistry could make use of the new native CAS/CAD commands introduced in Redis 8.4, which will be available in Spring Data Redis 4.1.0.
A proper example would be the RedisSpinLock which could use the new deleteIfEqual(lockKey, clientId) template method instead of the current Lua script.
Furthermore, the current OBTAIN_LOCK_SCRIPT could be simplified by calling SET with the IFEQ option instead of calling two separate commands.
Current Behavior
RedisLockRegistry currently uses Lua scripts to call multiple operations as one command.
Additionally, RedisMessageStore.doRemove() performs two separate operations which can be replaced with the currently available template command setGet() introduced in Redis 6.2 as GETDEL.
Context
The Redis OSS ecosystem team would like to contribute this enhancement.
The current Lua script approach works correctly but introduces overhead from script parsing and execution. With Redis 8.4 introducing native CAS/CAD commands, there's an opportunity to simplify the implementation and improve performance.
We aim to:
- Replace applicable Lua scripts with native Redis 8.4 CAS/CAD commands
- Simplify code maintenance by using direct API calls instead of embedded Lua scripts
- Optimize RedisMessageStore.doRemove() using GETDEL for atomic get-and-delete
Questions for the maintainers:
- Is this change meaningful to you?
- Do you have backwards compatibility requirements?
- Should we maintain support for Redis versions prior to 8.4?
- If yes, what is your preferred approach:
- Runtime detection with fallback to Lua scripts?
- Configuration option to choose implementation?
- Separate implementation classes?
- What is the lowest Redis version you would like to support?
RedisLockRegistrycould make use of the new native CAS/CAD commands introduced in Redis 8.4, which will be available in Spring Data Redis 4.1.0.A proper example would be the
RedisSpinLockwhich could use the newdeleteIfEqual(lockKey, clientId)template method instead of the current Lua script.Furthermore, the current
OBTAIN_LOCK_SCRIPTcould be simplified by calling SET with the IFEQ option instead of calling two separate commands.Current Behavior
RedisLockRegistrycurrently uses Lua scripts to call multiple operations as one command.Additionally,
RedisMessageStore.doRemove()performs two separate operations which can be replaced with the currently available template commandsetGet()introduced in Redis 6.2 as GETDEL.Context
The Redis OSS ecosystem team would like to contribute this enhancement.
The current Lua script approach works correctly but introduces overhead from script parsing and execution. With Redis 8.4 introducing native CAS/CAD commands, there's an opportunity to simplify the implementation and improve performance.
We aim to:
Questions for the maintainers: