All Projects → bsm → Redislock

bsm / Redislock

Licence: other
Simplified distributed locking implementation using Redis

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Redislock

Foundatio
Pluggable foundation blocks for building distributed apps.
Stars: ✭ 1,365 (+268.92%)
Mutual labels:  lock, redis, distributed
Pottery
Redis for humans. 🌎🌍🌏
Stars: ✭ 204 (-44.86%)
Mutual labels:  lock, redis, distributed
Redlock Php
Redis distributed locks in PHP
Stars: ✭ 651 (+75.95%)
Mutual labels:  lock, redis, distributed
Redisson
Redisson - Redis Java client with features of In-Memory Data Grid. Over 50 Redis based Java objects and services: Set, Multimap, SortedSet, Map, List, Queue, Deque, Semaphore, Lock, AtomicLong, Map Reduce, Publish / Subscribe, Bloom filter, Spring Cache, Tomcat, Scheduler, JCache API, Hibernate, MyBatis, RPC, local cache ...
Stars: ✭ 17,972 (+4757.3%)
Mutual labels:  lock, redis, distributed
Spring Boot Start Current
Spring Boot 脚手架 Mybatis Spring Security JWT 权限 Spring Cache + Redis
Stars: ✭ 246 (-33.51%)
Mutual labels:  redis, distributed
Spring Boot Klock Starter
基于redis的分布式锁组件,简单方便快捷接入项目,使项目拥有分布式锁能力
Stars: ✭ 546 (+47.57%)
Mutual labels:  lock, redis
Live Mutex
High-performance networked mutex for Node.js libraries.
Stars: ✭ 118 (-68.11%)
Mutual labels:  lock, redis
Easy
开源的Java开发脚手架,工作经验总结,springboot,springcloud,基于tk-mybatis代码反向生成,基于redis(redisson)注解形式加分布式锁等,计划将用该脚手架抄袭jeesite和ruoyi还有基于vue的后台权限管理系统做一套开源的后台管理和cms系统,域名服务器已买好,脚手架还在继续更新中,更新完毕开始更新easysite
Stars: ✭ 160 (-56.76%)
Mutual labels:  lock, redis
Aioredlock
🔒 The asyncio implemetation of Redis distributed locks
Stars: ✭ 171 (-53.78%)
Mutual labels:  lock, redis
Ninja Mutex
Mutex implementation for PHP
Stars: ✭ 180 (-51.35%)
Mutual labels:  lock, redis
slow-down
A centralized Redis-based lock to help you wait on throttled resources
Stars: ✭ 21 (-94.32%)
Mutual labels:  lock, distributed
Diplomat
A HTTP Ruby API for Consul
Stars: ✭ 358 (-3.24%)
Mutual labels:  lock, distributed
Redlock Rb
Redlock is a redis-based distributed lock implementation in Ruby
Stars: ✭ 385 (+4.05%)
Mutual labels:  lock, redis
distlock
The universal component of distributed locks in golang , support redis and postgresql
Stars: ✭ 60 (-83.78%)
Mutual labels:  lock, distributed
Lock
高性能分布式并发锁, 行为限流
Stars: ✭ 260 (-29.73%)
Mutual labels:  lock, redis
Dsock
Distributed WebSocket broker
Stars: ✭ 197 (-46.76%)
Mutual labels:  redis, distributed
Spoon
🥄 A package for building specific Proxy Pool for different Sites.
Stars: ✭ 173 (-53.24%)
Mutual labels:  redis, distributed
Zi5book
book.zi5.me全站kindle电子书籍爬取,按照作者书籍名分类,每本书有mobi和equb两种格式,采用分布式进行全站爬取
Stars: ✭ 191 (-48.38%)
Mutual labels:  redis, distributed
Javainterview
java中高级基础指南
Stars: ✭ 222 (-40%)
Mutual labels:  lock, redis
Redsync.go
*DEPRECATED* Please use https://gopkg.in/redsync.v1 (https://github.com/go-redsync/redsync)
Stars: ✭ 292 (-21.08%)
Mutual labels:  redis, distributed

redislock

Build Status GoDoc Go Report Card License

Simplified distributed locking implementation using Redis. For more information, please see examples.

Examples

import (
  "fmt"
  "time"

  "github.com/bsm/redislock"
  "github.com/go-redis/redis/v8"
)

func main() {
	// Connect to redis.
	client := redis.NewClient(&redis.Options{
		Network:	"tcp",
		Addr:		"127.0.0.1:6379",
	})
	defer client.Close()

	// Create a new lock client.
	locker := redislock.New(client)

	ctx := context.Background()

	// Try to obtain lock.
	lock, err := locker.Obtain(ctx, "my-key", 100*time.Millisecond, nil)
	if err == redislock.ErrNotObtained {
		fmt.Println("Could not obtain lock!")
	} else if err != nil {
		log.Fatalln(err)
	}

	// Don't forget to defer Release.
	defer lock.Release(ctx)
	fmt.Println("I have a lock!")

	// Sleep and check the remaining TTL.
	time.Sleep(50 * time.Millisecond)
	if ttl, err := lock.TTL(ctx); err != nil {
		log.Fatalln(err)
	} else if ttl > 0 {
		fmt.Println("Yay, I still have my lock!")
	}

	// Extend my lock.
	if err := lock.Refresh(ctx, 100*time.Millisecond, nil); err != nil {
		log.Fatalln(err)
	}

	// Sleep a little longer, then check.
	time.Sleep(100 * time.Millisecond)
	if ttl, err := lock.TTL(ctx); err != nil {
		log.Fatalln(err)
	} else if ttl == 0 {
		fmt.Println("Now, my lock has expired!")
	}

}

Documentation

Full documentation is available on GoDoc

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].