public function acquireLock($id) { $this->lockKey = $this->lockKeyStart . $id; $lockValue = substr(Common::generateUniqId(), 0, 12); $locked = $this->backend->setIfNotExists($this->lockKey, $lockValue, $ttlInSeconds = 60); if ($locked) { $this->lockValue = $lockValue; } return $locked; }
public function test_getTimeToLive_ShouldReturnTheNumberOfTimeLeft_IfExpires() { $success = $this->redis->setIfNotExists($this->key, 'test', 60); $this->assertTrue($success); $timeToLive = $this->redis->getTimeToLive($this->key); $this->assertGreaterThanOrEqual(40000, $timeToLive); }