UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'ky+S32FWyB8mrQYnSJfcXvIsmV9v36kFMt0vWhM+Rk8='
WHERE
key_id = 'c46f7a8489d9db7e875fb3f4c6075c64b542b54df08eab8e3a35d9762b50462e'
AND (
token = 'ky+S32FWyB8mrQYnSJfcXvIsmV9v36kFMt0vWhM+Rk8='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)