UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'vmEIuJyDdoi6yXBqpY+P1SdyXwXSZfKp1sw+aASofOg=' 
WHERE 
  key_id = '39c712e21fecc5e941844d084b1d111c42b3efafd078521ede8a5877dc860e10' 
  AND (
    token = 'vmEIuJyDdoi6yXBqpY+P1SdyXwXSZfKp1sw+aASofOg=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00031