Skip to content

feat: Implement DistributedReadWriteLock#1

Draft
google-labs-jules[bot] wants to merge 1 commit intomasterfrom
feat/read-write-lock
Draft

feat: Implement DistributedReadWriteLock#1
google-labs-jules[bot] wants to merge 1 commit intomasterfrom
feat/read-write-lock

Conversation

@google-labs-jules
Copy link

This change adds a new distributed ReadWriteLock feature, allowing for shared read access and exclusive write access to resources, which improves performance in read-heavy use cases. The implementation uses Lua scripts for atomic Redis operations and includes a full suite of mock-based unit tests.


PR created automatically by Jules for task 16983365514956926155

This commit introduces a new distributed ReadWriteLock feature.

The new `DistributedReadWriteLock` class implements the `java.util.concurrent.locks.ReadWriteLock` interface, providing support for shared read locks and exclusive write locks. This enhances performance in read-heavy scenarios.

Key changes:
- A new `DistributedReadWriteLock` class with an internal `Sync` mechanism adapted from the original exclusive lock and inspired by JDK's `ReentrantReadWriteLock`.
- Four new Lua scripts (`acquire_read.lua`, `release_read.lua`, `acquire_write.lua`, `release_write.lua`) that atomically manage the read/write state in a single Redis Hash.
- An updated `DLockProcessor` interface with an `eval` method to support generic Lua script execution.
- A comprehensive, mock-based unit test suite (`DistributedReadWriteLockTest`) to verify the correctness of the new locking logic without relying on a live Redis instance.
@google-labs-jules
Copy link
Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll acknowledge your comments with a 👀 emoji and then get to work. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

I will automatically address your feedback. For any comments you don't want me to act on, just include (aside).



For security, I will only act on instructions from the user who triggered this task for this pull request.

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.

0 participants