From 8f45575379c4e6b728771d19a59c224e141705c2 Mon Sep 17 00:00:00 2001 From: Markus Fischer Date: Fri, 30 Jan 2015 17:56:17 +0100 Subject: [PATCH] Allow subclasses to override how the token is generated. --- src/RedLock.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/RedLock.php b/src/RedLock.php index 201feaf..0a085d4 100644 --- a/src/RedLock.php +++ b/src/RedLock.php @@ -26,7 +26,7 @@ public function lock($resource, $ttl) { $this->initInstances(); - $token = uniqid(); + $token = $this->generateToken(); $retry = $this->retryCount; do { @@ -82,6 +82,10 @@ public function unlock($lock) } } + protected function generateToken() { + return uniqid(); + } + private function initInstances() { if (empty($this->instances)) {