UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'JZ8SjUJBPeO7lRMjdMyrW0k6tyF7UIIHmXiLfMGfgkk=' 
WHERE 
  key_id = '8fa4dc11256571ef58484863b3ff0834ac0e5966e1766e8e744b682c84e27657' 
  AND (
    token = 'JZ8SjUJBPeO7lRMjdMyrW0k6tyF7UIIHmXiLfMGfgkk=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00021