UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'D99QjTCgyLCSyTIPIXprJVce7TFMqylqSa11qM531DQ=' 
WHERE 
  key_id = '31b2ea978b33cf51bd08d18df7ac0c6a739be2dde9ddcbd532accc96a69aaf12' 
  AND (
    token = 'D99QjTCgyLCSyTIPIXprJVce7TFMqylqSa11qM531DQ=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00017