UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'xEu4rWSyRL96qBrxNft3gE6ZwknK6VaSoavyHQO2ik0='
WHERE
key_id = 'e7f8a39645572561ebe2a17567412e9b1d9c97424c2c4a48b42273ae3f23bfdc'
AND (
token = 'xEu4rWSyRL96qBrxNft3gE6ZwknK6VaSoavyHQO2ik0='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)