Skip to content

Straight forward typescript decorator for distributed locking using redis⚡

Notifications You must be signed in to change notification settings

saranonearth/redis-acquire-lock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

redis-acquire-lock

Straight forward typescript decorator for distributed locking using redis⚡

Using function parameter as key

class UserService {
    @AcquireLock({key: (args) => args[0] + "MX_W", ttl: 2000})
    public createTransaction(userId: string, txType: string) {
        console.log('Function Logic');
    }
}

Using string as key

class UserService {
    @AcquireLock({key: "some_key", ttl: 2000})
    public createTransaction(userId: string, txType: string) {
        console.log('Function Logic');
    }
}

Using function parameter by index

class UserService {
    @AcquireLock({key: [1], ttl: 2000})
    public createTransaction(userId: string, txType: string) {
        console.log('Function Logic');
    }
}

About

Straight forward typescript decorator for distributed locking using redis⚡

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published