Straight forward typescript decorator for distributed locking using redis⚡
class UserService {
@AcquireLock({key: (args) => args[0] + "MX_W", ttl: 2000})
public createTransaction(userId: string, txType: string) {
console.log('Function Logic');
}
}
class UserService {
@AcquireLock({key: "some_key", ttl: 2000})
public createTransaction(userId: string, txType: string) {
console.log('Function Logic');
}
}
class UserService {
@AcquireLock({key: [1], ttl: 2000})
public createTransaction(userId: string, txType: string) {
console.log('Function Logic');
}
}