@@ -59,27 +59,27 @@ public function acquire()
59
59
60
60
try {
61
61
$ this ->connection ->table ($ this ->table )->insert ([
62
- 'id ' => $ this ->name ,
62
+ 'key ' => $ this ->name ,
63
63
'owner ' => $ this ->owner ,
64
- 'expires_at ' => $ this ->expiresAt (),
64
+ 'expiration ' => $ this ->expiresAt (),
65
65
]);
66
66
67
67
$ acquired = true ;
68
68
} catch (QueryException $ e ) {
69
69
$ updated = $ this ->connection ->table ($ this ->table )
70
- ->where ('id ' , $ this ->name )
70
+ ->where ('key ' , $ this ->name )
71
71
->where (function ($ query ) {
72
- return $ query ->where ('owner ' , $ this ->owner )->orWhere ('expires_at ' , '<= ' , time ());
72
+ return $ query ->where ('owner ' , $ this ->owner )->orWhere ('expiration ' , '<= ' , time ());
73
73
})->update ([
74
74
'owner ' => $ this ->owner ,
75
- 'expires_at ' => $ this ->expiresAt (),
75
+ 'expiration ' => $ this ->expiresAt (),
76
76
]);
77
77
78
78
$ acquired = $ updated >= 1 ;
79
79
}
80
80
81
81
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 ();
83
83
}
84
84
85
85
return $ acquired ;
@@ -104,7 +104,7 @@ public function release()
104
104
{
105
105
if ($ this ->isOwnedByCurrentProcess ()) {
106
106
$ this ->connection ->table ($ this ->table )
107
- ->where ('id ' , $ this ->name )
107
+ ->where ('key ' , $ this ->name )
108
108
->where ('owner ' , $ this ->owner )
109
109
->delete ();
110
110
@@ -122,7 +122,7 @@ public function release()
122
122
public function forceRelease ()
123
123
{
124
124
$ this ->connection ->table ($ this ->table )
125
- ->where ('id ' , $ this ->name )
125
+ ->where ('key ' , $ this ->name )
126
126
->delete ();
127
127
}
128
128
@@ -133,6 +133,6 @@ public function forceRelease()
133
133
*/
134
134
protected function getCurrentOwner ()
135
135
{
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 ;
137
137
}
138
138
}
0 commit comments