-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow lock Redis from global detached context. (#350)
Allow lock Redis from global detached context. Sometimes we need to perfrom operation on Redis from a background thread, for this we need to lock Redis. We can use `ThreadSafeContext` but we might prefer not to for the following reasons: 1. Creating a `ThreadSafeContext` is costly. 2. `ThreadSafeContext` which is not attached to a client do not have the module pointer and this could cause some operations to fail. The PR adds the ability to lock Redis using the global detached context. After locking, we will get `DetachedContextGuard` object which will automatically unlock Redis when dispose. `DetachedContextGuard` implements `Deref<Context>` so it can be used just like a regular `Context` to perform operations. **Notice: This context should not be use to return any replies!!!** Future improvement is to seperate contexts for command invocation and replies so those can not be accidently misstaken, notice that this PR do not introduce any regression regarding this topic because we already have this issue with `ThreadSafeContext`.
- Loading branch information
1 parent
732b2bc
commit 9fe7eac
Showing
4 changed files
with
88 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters