UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'Us982z2PCDDefRMNA4tr0NBzvmy3NTHovAptixEbW+U=' 
WHERE 
  key_id = '7df72488e8b266a19a6b110685c283698f02acc162dc3c080f373bd921271345' 
  AND (
    token = 'Us982z2PCDDefRMNA4tr0NBzvmy3NTHovAptixEbW+U=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00040