Documentation
¶
Overview ¶
Package local provides local (single-instance) lock implementations.
These locks use standard Go sync primitives (sync.Mutex and sync.RWMutex) and are suitable for single-instance deployments. They ignore TTL parameters since local locks don't expire.
Index ¶
- func NewLocker() lock.Locker
- func NewRWLocker() lock.RWLocker
- type Locker
- type RWLocker
- func (rw *RWLocker) Lock(ctx context.Context, key string, _ time.Duration) error
- func (rw *RWLocker) RLock(ctx context.Context, key string, _ time.Duration) error
- func (rw *RWLocker) RUnlock(_ context.Context, key string) error
- func (rw *RWLocker) TryLock(ctx context.Context, key string, _ time.Duration) (bool, error)
- func (rw *RWLocker) Unlock(ctx context.Context, key string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRWLocker ¶
NewRWLocker creates a new local read-write locker.
Types ¶
type Locker ¶
type Locker struct {
// contains filtered or unexported fields
}
Locker implements lock.Locker using lock striping (sharded mutexes). Uses a fixed pool of mutexes to avoid unbounded memory growth while still providing per-key locking semantics with good concurrency.
func (*Locker) Lock ¶
Lock acquires an exclusive lock. The ttl parameter is ignored, but the key is used for sharding.
type RWLocker ¶
type RWLocker struct {
// contains filtered or unexported fields
}
RWLocker implements lock.RWLocker using sync.RWMutex.
func (*RWLocker) Lock ¶
Lock acquires an exclusive lock. The ttl parameter is ignored, but the key is used for sharding.
func (*RWLocker) RLock ¶
RLock acquires a shared read lock. The ttl parameter is ignored, but the key is used for sharding.