NewLocker initializes a new Locker instance with a Redis client, a key, and a value. Parameters: - client: A Redis universal client to interact with Redis. - key: The unique identifier for the lock. - value: A unique value to associate with the lock (ensures lock ownership). Returns a pointer to a n
(client redis.UniversalClient, key, value string)
| 71 | // - value: A unique value to associate with the lock (ensures lock ownership). |
| 72 | // Returns a pointer to a new Locker instance. |
| 73 | func NewLocker(client redis.UniversalClient, key, value string) *Locker { |
| 74 | return &Locker{ |
| 75 | client: client, |
| 76 | key: key, |
| 77 | value: value, |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | // Lock attempts to acquire the lock for the specified key with a timeout. |
| 82 | // If the lock is already held, it returns an error indicating the lock is unavailable. |
no outgoing calls