Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Dec 16, 2020
1 parent fe37ece commit 3d95235
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 27 deletions.
12 changes: 5 additions & 7 deletions src/Illuminate/Cache/CacheManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@ protected function createRedisDriver(array $config)

$store = new RedisStore($redis, $this->getPrefix($config), $connection);

$store->setLockConnection($config['lock_connection'] ?? $connection);

return $this->repository($store);
return $this->repository(
$store->setLockConnection($config['lock_connection'] ?? $connection)
);
}

/**
Expand All @@ -224,11 +224,9 @@ protected function createDatabaseDriver(array $config)
$config['lock_lottery'] ?? [2, 100]
);

$store->setLockConnection(
return $this->repository($store->setLockConnection(
$this->app['db']->connection($config['lock_connection'] ?? $config['connection'] ?? null)
);

return $this->repository($store);
));
}

/**
Expand Down
12 changes: 6 additions & 6 deletions src/Illuminate/Cache/DatabaseLock.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,22 +128,22 @@ public function forceRelease()
}

/**
* Get the name of the database connection.
* Returns the owner value written into the driver for this lock.
*
* @return string
*/
public function getConnectionName()
protected function getCurrentOwner()
{
return $this->connection->getName();
return optional($this->connection->table($this->table)->where('key', $this->name)->first())->owner;
}

/**
* Returns the owner value written into the driver for this lock.
* Get the name of the database connection being used to manage the lock.
*
* @return string
*/
protected function getCurrentOwner()
public function getConnectionName()
{
return optional($this->connection->table($this->table)->where('key', $this->name)->first())->owner;
return $this->connection->getName();
}
}
8 changes: 5 additions & 3 deletions src/Illuminate/Cache/DatabaseStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class DatabaseStore implements LockProvider, Store
protected $connection;

/**
* The database connection instance for the lock.
* The database connection instance that should be used to manage locks.
*
* @var \Illuminate\Database\ConnectionInterface
*/
Expand Down Expand Up @@ -339,14 +339,16 @@ public function getConnection()
}

/**
* Set the lock connection to be used.
* Specify the name of the connection that should be used to manage locks.
*
* @param \Illuminate\Database\ConnectionInterface $connection
* @return void
* @return $this
*/
public function setLockConnection($connection)
{
$this->lockConnection = $connection;

return $this;
}

/**
Expand Down
12 changes: 6 additions & 6 deletions src/Illuminate/Cache/RedisLock.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,22 @@ public function forceRelease()
}

/**
* Get the name of the Redis connection.
* Returns the owner value written into the driver for this lock.
*
* @return string
*/
public function getConnectionName()
protected function getCurrentOwner()
{
return $this->redis->getName();
return $this->redis->get($this->name);
}

/**
* Returns the owner value written into the driver for this lock.
* Get the name of the Redis connection being used to manage the lock.
*
* @return string
*/
protected function getCurrentOwner()
public function getConnectionName()
{
return $this->redis->get($this->name);
return $this->redis->getName();
}
}
12 changes: 7 additions & 5 deletions src/Illuminate/Cache/RedisStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class RedisStore extends TaggableStore implements LockProvider
protected $prefix;

/**
* The Redis connection that should be used.
* The Redis connection instance that should be used to manage locks.
*
* @var string
*/
Expand Down Expand Up @@ -250,7 +250,7 @@ public function connection()
}

/**
* Get the Redis connection instance for the lock.
* Get the Redis connection instance that should be used to manage locks.
*
* @return \Illuminate\Redis\Connections\Connection
*/
Expand All @@ -260,7 +260,7 @@ public function lockConnection()
}

/**
* Set the connection name to be used.
* Specify the name of the connection that should be used to store data.
*
* @param string $connection
* @return void
Expand All @@ -271,14 +271,16 @@ public function setConnection($connection)
}

/**
* Set the lock connection name to be used.
* Specify the name of the connection that should be used to manage locks.
*
* @param string $connection
* @return void
* @return $this
*/
public function setLockConnection($connection)
{
$this->lockConnection = $connection;

return $this;
}

/**
Expand Down

0 comments on commit 3d95235

Please sign in to comment.