UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'cqLejzhdaMe9GeGOoJbs8CuO6n8YLdjlVtoOGf8/hUs='
WHERE
key_id = 'bf603849f17cc42d1a3078288cc21b4d3166b9c561ed61a9bdc95125f727d2ee'
AND (
token = 'cqLejzhdaMe9GeGOoJbs8CuO6n8YLdjlVtoOGf8/hUs='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)