UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'DIulGM6O0pEPbwVkINCXIep1naAzNLTrWkLYbPulWyw=' 
WHERE 
  key_id = '6dd52ea7ba9d178ced9f331d120975456c9268297565505e47550b1ce8f7efc9' 
  AND (
    token = 'DIulGM6O0pEPbwVkINCXIep1naAzNLTrWkLYbPulWyw=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00035