diff --git a/src/Illuminate/Cache/CacheManager.php b/src/Illuminate/Cache/CacheManager.php index ce33b7b32049..c8c8f602808b 100755 --- a/src/Illuminate/Cache/CacheManager.php +++ b/src/Illuminate/Cache/CacheManager.php @@ -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) + ); } /** @@ -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); + )); } /** diff --git a/src/Illuminate/Cache/DatabaseLock.php b/src/Illuminate/Cache/DatabaseLock.php index a35eceb2d2e8..7fd05c19134a 100644 --- a/src/Illuminate/Cache/DatabaseLock.php +++ b/src/Illuminate/Cache/DatabaseLock.php @@ -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(); } } diff --git a/src/Illuminate/Cache/DatabaseStore.php b/src/Illuminate/Cache/DatabaseStore.php index b02067c4de33..32d7a9fc0676 100755 --- a/src/Illuminate/Cache/DatabaseStore.php +++ b/src/Illuminate/Cache/DatabaseStore.php @@ -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 */ @@ -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; } /** diff --git a/src/Illuminate/Cache/RedisLock.php b/src/Illuminate/Cache/RedisLock.php index a82dad449a1d..481b811d398f 100644 --- a/src/Illuminate/Cache/RedisLock.php +++ b/src/Illuminate/Cache/RedisLock.php @@ -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(); } } diff --git a/src/Illuminate/Cache/RedisStore.php b/src/Illuminate/Cache/RedisStore.php index 66c6296a60bf..cdf1c8fca094 100755 --- a/src/Illuminate/Cache/RedisStore.php +++ b/src/Illuminate/Cache/RedisStore.php @@ -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 */ @@ -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 */ @@ -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 @@ -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; } /**