UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'SgpPeL3Vb5dEetX9mdE2K8sxf6KczwJwaazeMTpa5xw='
WHERE
key_id = '188a4c10d7d817256ebdc7773e9a58575e9ed0c048e79ae38123f120645d7074'
AND (
token = 'SgpPeL3Vb5dEetX9mdE2K8sxf6KczwJwaazeMTpa5xw='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)