///
/**
* @file ELock
* @author Yourtion Guo
*/
import { Redis } from "ioredis";
export interface IELockOptions {
prefix?: string;
timeout?: number;
}
/**
* Easy use distributed redis lock implementation
*
* @class ELock
*/
declare class ELock {
private client;
private prefix;
private timeout;
/**
* Creates an instance of ELock.
* @param {Redis} redis ioredis client
* @param {IELockOptions} options options
* @memberof ELock
*/
constructor(redis: Redis, options: IELockOptions);
/**
* Acquire a lock (fail will throw a error)
*
* @param {string} [key="default"] lock key
* @param {number} [timeout=this.timeout] lock time (ms)
* @memberof ELock
*/
acquire(key?: string, timeout?: number): any;
/**
* Get a lock (fail will return null)
*
* @param {string} [key="default"] lock key
* @param {number} [timeout=this.timeout] lock time (ms)
* @memberof ELock
*/
get(key?: string, timeout?: number): any;
/**
* Release the lock
*
* @param {string} [key="default"] lock key
* @memberof ELock
*/
release(key?: string): any;
/**
* Check is locked
*
* @param {string} [key="default"] lock key
* @memberof ELock
*/
locked(key?: string): any;
/**
* Get the real lock key in redis
*
* @private
* @param {string} key
* @returns {string}
* @memberof ELock
*/
private getKey(key);
}
export default ELock;