lockmanager

Contributions Welcome Release

Lock Manager Package

The Lock Manager package provides a unified and extensible distributed locking interface for Go applications. It offers a consistent way to implement distributed locks across different services, making it easy to coordinate access to shared resources in distributed systems.

Features

  • Unified Interface: Consistent API for different lock implementations

  • Redis Implementation: Built-in support for Redis-based distributed locks

    • Customizable Lock Options: Configure lock behavior with options like TTL and retry parameters

    • Context Support: All operations respect context cancellation and deadlines

  • LocalLock Implementation: Simple in-memory lock for local use cases

    • Custom Token Generation: Optionally provide custom token generation logic

    • Auto Cleanup: Locks are automatically cleaned up when ttl expires

Installation

  • LocalLock

    go get github.com/kittipat1413/go-common/framework/lockmanager/locallock
  • Redsync

    go get github.com/kittipat1413/go-common/framework/lockmanager/redsync

Documentation

Go Reference

For detailed API documentation, examples, and usage patterns, visit the Go Package Documentation.

Usage

Locking Interface The core of the package is the LockManager interface:

🚀 Getting Started with Redis

Create Redis LockManager

🔐 Acquire Lock

🔓 Release Lock

⚙️ Advanced Configuration

Example

You can find a complete working example in the repository under framework/lockmanager/example.

Last updated