<?php
namespace Illuminate\Cache;
class RedisLock extends Lock
{
protected $redis;
public function __construct($redis, $name, $seconds, $owner = null)
{
parent::__construct($name, $seconds, $owner);
$this->redis = $redis;
}
public function acquire()
{
if ($this->seconds > 0) {
return $this->redis->set($this->name, $this->owner, 'EX', $this->seconds, 'NX') == true;
}
return $this->redis->setnx($this->name, $this->owner) === 1;
}