This pull request introduces a new LockManager feature to manage distributed locks, which is particularly useful for synchronized access to resources by multiple goroutines. The changes include the implementation of the LockManager class, updates to the documentation, and new test cases to ensure its functionality.
Implementation of LockManager:
cache.go: Added the LockManager class with methods for creating a new instance, locking, unlocking, and retrieving mutexes associated with specific keys. This includes a double-check locking mechanism to improve performance in read-heavy scenarios.
Documentation updates:
README.md: Added detailed documentation for the LockManager, including examples of using GetAndLock and explicit Lock and Unlock methods. [1][2]
Testing:
cache_test.go: Added a new test case TestLockManager to verify the functionality of the LockManager and an example usage function ExampleLockManager.
This pull request introduces a new
LockManager
feature to manage distributed locks, which is particularly useful for synchronized access to resources by multiple goroutines. The changes include the implementation of theLockManager
class, updates to the documentation, and new test cases to ensure its functionality.Implementation of
LockManager
:cache.go
: Added theLockManager
class with methods for creating a new instance, locking, unlocking, and retrieving mutexes associated with specific keys. This includes a double-check locking mechanism to improve performance in read-heavy scenarios.Documentation updates:
README.md
: Added detailed documentation for theLockManager
, including examples of usingGetAndLock
and explicitLock
andUnlock
methods. [1] [2]Testing:
cache_test.go
: Added a new test caseTestLockManager
to verify the functionality of theLockManager
and an example usage functionExampleLockManager
.