UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'W982tIZIqJ6qLXgJquLPNm7vEM1UkMvPWCIxlepVVWA='
WHERE
key_id = '9094e2ebb1d202c1b68abe6f48f64389478689207e3e98f45f89e2b22dea2c3f'
AND (
token = 'W982tIZIqJ6qLXgJquLPNm7vEM1UkMvPWCIxlepVVWA='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)