UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'sa7AeMAG0YJsXo2q9KNcDwa6HIabXFHcRmy8Y111Gh0='
WHERE
key_id = '32f5bf4034c5320afa19473c3c855db47e031e1404f13718f922a22182736a65'
AND (
token = 'sa7AeMAG0YJsXo2q9KNcDwa6HIabXFHcRmy8Y111Gh0='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)