Skip to content

Commit 573831b

Browse files
committed
update columns
1 parent 5adfcd5 commit 573831b

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/Illuminate/Cache/DatabaseLock.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -59,27 +59,27 @@ public function acquire()
5959

6060
try {
6161
$this->connection->table($this->table)->insert([
62-
'id' => $this->name,
62+
'key' => $this->name,
6363
'owner' => $this->owner,
64-
'expires_at' => $this->expiresAt(),
64+
'expiration' => $this->expiresAt(),
6565
]);
6666

6767
$acquired = true;
6868
} catch (QueryException $e) {
6969
$updated = $this->connection->table($this->table)
70-
->where('id', $this->name)
70+
->where('key', $this->name)
7171
->where(function ($query) {
72-
return $query->where('owner', $this->owner)->orWhere('expires_at', '<=', time());
72+
return $query->where('owner', $this->owner)->orWhere('expiration', '<=', time());
7373
})->update([
7474
'owner' => $this->owner,
75-
'expires_at' => $this->expiresAt(),
75+
'expiration' => $this->expiresAt(),
7676
]);
7777

7878
$acquired = $updated >= 1;
7979
}
8080

8181
if (random_int(1, $this->lottery[1]) <= $this->lottery[0]) {
82-
$this->connection->table($this->table)->where('expires_at', '<=', time())->delete();
82+
$this->connection->table($this->table)->where('expiration', '<=', time())->delete();
8383
}
8484

8585
return $acquired;
@@ -104,7 +104,7 @@ public function release()
104104
{
105105
if ($this->isOwnedByCurrentProcess()) {
106106
$this->connection->table($this->table)
107-
->where('id', $this->name)
107+
->where('key', $this->name)
108108
->where('owner', $this->owner)
109109
->delete();
110110

@@ -122,7 +122,7 @@ public function release()
122122
public function forceRelease()
123123
{
124124
$this->connection->table($this->table)
125-
->where('id', $this->name)
125+
->where('key', $this->name)
126126
->delete();
127127
}
128128

@@ -133,6 +133,6 @@ public function forceRelease()
133133
*/
134134
protected function getCurrentOwner()
135135
{
136-
return optional($this->connection->table($this->table)->where('id', $this->name)->first())->owner;
136+
return optional($this->connection->table($this->table)->where('key', $this->name)->first())->owner;
137137
}
138138
}

tests/Integration/Database/DatabaseLockTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ protected function setUp(): void
1717
parent::setUp();
1818

1919
Schema::create('cache_locks', function (Blueprint $table) {
20-
$table->string('id')->primary();
20+
$table->string('key')->primary();
2121
$table->string('owner');
22-
$table->integer('expires_at');
22+
$table->integer('expiration');
2323
});
2424
}
2525

@@ -55,7 +55,7 @@ public function testExpiredLockCanBeRetrieved()
5555
{
5656
$lock = Cache::driver('database')->lock('foo');
5757
$this->assertTrue($lock->get());
58-
DB::table('cache_locks')->update(['expires_at' => now()->subDays(1)->getTimestamp()]);
58+
DB::table('cache_locks')->update(['expiration' => now()->subDays(1)->getTimestamp()]);
5959

6060
$otherLock = Cache::driver('database')->lock('foo');
6161
$this->assertTrue($otherLock->get());

0 commit comments

Comments
 (0)