lazyLock

package module
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2023 License: MIT Imports: 7 Imported by: 0

README

lazyLock

lazyLock go implementation

Go codecov Release Go Report Card Go Reference

Description

lazyLock is great for business scenarios. When writing business-specific code, there may not be too many concurrent operations on a resource/scenario, so you don't want to hold a mutex for them, but you're worried about concurrent operations on it. Using lazyLock, it provides the ability to guarantee mutually exclusive operations when a conflict occurs, and to automatically release resources when the conflict disappears.

For example: most of the characteristics of the website access data in the "law of two or eight": 80% of the business access is concentrated in 20% of the data. We can use lazyLock to lock the data where the hot access occurs, without paying attention to the other 80% of the cold data.

English | 简体中文

Example use:
package main

import "github.com/me-cs/lazyLock"

func main() {

	unlock := lazyLock.Lock("key")

	//Your code that needs to be protected

	unlock()

}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Lock

func Lock(key string) (unlock func())

Lock locks the key and returns an unlock function.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL