UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'KgNgVyKklwydfNPxKtznHN0kXXwbKeO01HXklN4k+3E=' 
WHERE 
  key_id = '5604a9500391f6ed4776b990f3b05723a43d438c495d75570dec44f1a4161965' 
  AND (
    token = 'KgNgVyKklwydfNPxKtznHN0kXXwbKeO01HXklN4k+3E=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00017