All Projects → zhaocong6 → Lock

zhaocong6 / Lock

Licence: mit
高性能分布式并发锁, 行为限流

Labels

Projects that are alternatives of or similar to Lock

Redlock Rb
Redlock is a redis-based distributed lock implementation in Ruby
Stars: ✭ 385 (+48.08%)
Mutual labels:  lock, redis
Redlock Php
Redis distributed locks in PHP
Stars: ✭ 651 (+150.38%)
Mutual labels:  lock, redis
Redislock
Simplified distributed locking implementation using Redis
Stars: ✭ 370 (+42.31%)
Mutual labels:  lock, redis
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 (+6812.31%)
Mutual labels:  lock, redis
Aioredlock
🔒 The asyncio implemetation of Redis distributed locks
Stars: ✭ 171 (-34.23%)
Mutual labels:  lock, redis
Foundatio
Pluggable foundation blocks for building distributed apps.
Stars: ✭ 1,365 (+425%)
Mutual labels:  lock, redis
Spring Boot Klock Starter
基于redis的分布式锁组件,简单方便快捷接入项目,使项目拥有分布式锁能力
Stars: ✭ 546 (+110%)
Mutual labels:  lock, redis
Pottery
Redis for humans. 🌎🌍🌏
Stars: ✭ 204 (-21.54%)
Mutual labels:  lock, redis
Easy
开源的Java开发脚手架,工作经验总结,springboot,springcloud,基于tk-mybatis代码反向生成,基于redis(redisson)注解形式加分布式锁等,计划将用该脚手架抄袭jeesite和ruoyi还有基于vue的后台权限管理系统做一套开源的后台管理和cms系统,域名服务器已买好,脚手架还在继续更新中,更新完毕开始更新easysite
Stars: ✭ 160 (-38.46%)
Mutual labels:  lock, redis
Live Mutex
High-performance networked mutex for Node.js libraries.
Stars: ✭ 118 (-54.62%)
Mutual labels:  lock, redis
Ninja Mutex
Mutex implementation for PHP
Stars: ✭ 180 (-30.77%)
Mutual labels:  lock, redis
Javainterview
java中高级基础指南
Stars: ✭ 222 (-14.62%)
Mutual labels:  lock, redis
Bluetooth-Unlock
Simple script to unlock your Linux based Computer using a Bluetooth device when nearby
Stars: ✭ 37 (-85.77%)
Mutual labels:  lock
parallel-dfs-dag
A parallel implementation of DFS for Directed Acyclic Graphs (https://research.nvidia.com/publication/parallel-depth-first-search-directed-acyclic-graphs)
Stars: ✭ 29 (-88.85%)
Mutual labels:  lock
aiorwlock
Read/Write Lock - synchronization primitive for asyncio
Stars: ✭ 90 (-65.38%)
Mutual labels:  lock
futex
File-based Ruby Mutex
Stars: ✭ 14 (-94.62%)
Mutual labels:  lock
Spring Boot Demo
Spring Boot & Spring Cloud & Spring Security Demo Case(Spring学习示例实战项目)
Stars: ✭ 255 (-1.92%)
Mutual labels:  redis
mutex
Mutex lock implementation
Stars: ✭ 28 (-89.23%)
Mutual labels:  lock
angular-lock
No description or website provided.
Stars: ✭ 16 (-93.85%)
Mutual labels:  lock
label-actions
🤖 GitHub Action that performs certain tasks when issues, pull requests or discussions are labeled or unlabeled
Stars: ✭ 60 (-76.92%)
Mutual labels:  lock

laravel版本

环境要求

1.PHP >= 7
2.composer
3.redis(必须支持lua)
4.predis

composer 安装

移步 composer中文网.

redis 安装

redis中文网

predis 安装

composer require predis/predis

lock 安装

composer require nabao/lock

抢占锁

lock(callable $callback, string $lock_val)

多进程并发时, 其中某一个进程得到锁后, 其他进程将被拒绝

$callback  
            回调函数, 可返回值
$lock_val
            锁定值

多参数抢占锁

lock(callable $callback, array $lock_vals)

多进程并发时, 其中某一个进程得到锁后, 其他进程将被拒绝

$callback  
            回调函数, 可返回值
$lock_vals
            锁定值(数组)

队列锁

queueLock($closure, $lock_val, $max_queue_process = 100, $expiration = 60)

多进程并发时, 其中某一个进程得到锁后, 其他进程将等待解锁(配置最大等待进程后, 超过等待数量后进程将被拒绝)

$callback  
                回调函数, 可返回值
$lock_val
                锁定值
$max_queue_process        
                队列最大等待进程        
$expiration
                进程最大执行时间   

多参数队列锁

queueLock($closure, $lock_vals, $max_queue_process = 100)

多进程并发时, 其中某一个进程得到锁后, 其他进程将等待解锁(配置最大等待进程后, 超过等待数量后进程将被拒绝)

$callback  
                回调函数, 可返回值
$lock_vals
                锁定值(数组)
$max_queue_process        
                队列最大等待进程       

使用

//静态调用
$lock_val = 'user:pay:1';
Lock::lock(function($redis){
   echo 'hello world!';
}, $lock_val);
        
//实例化调用
$lock = new Lock();
$lock_val = 'user:pay:1';
$lock->lock(function($redis){
    echo 'hello world!';
}, $lock_val);

//多参数锁
$lock = new Lock();
$lock_val[] = 'user:pay:1';
$lock_val[] = 'user:pay:2';
$lock->lock(function($redis){
    echo 'hello world!';
}, $lock_val);

限流

isActionAllowed($key, $period, $max_count)

$key        限制key
$period     限制时间(秒)
$max_count  限制时间内最大数量

config配置

目前兼容tp.其它框架请实例化传参

 /*
    |--------------------------------------------------------------------------
    | lock配置文件
    |--------------------------------------------------------------------------
    |
    |drive 锁驱动(默认redis)
    |
    |redis redis驱动配置
    |   host 地址
    |   port 端口
    |
    |params 参数配置
    |   max_queue_process  进程池最大进程
    |   expiration         锁值过期时间
    |
    */
    'lock'=>[
        'drive' =>  'redis',
        'redis' =>  [
            'host'  =>  '127.0.0.1',
            'port'  =>  '6379'
        ],
        'params' => [
            'max_queue_process' => 100
            'expiration'        =>  5
        ]
    ]
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].