UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'qu2R0iWVQGGmwJELVikZQ96twECpzRWEK4k09ywyS4Y=' 
WHERE 
  key_id = '58936a295c454fac4ca52468904f6e6085f6440e90646cadfd851d16dd0e471a' 
  AND (
    token = 'qu2R0iWVQGGmwJELVikZQ96twECpzRWEK4k09ywyS4Y=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00036