Consistently move the misses update to just before the user function call (GH-11715) (GH-11716)

diff --git a/Lib/functools.py b/Lib/functools.py
index 592f156..b734899 100644
--- a/Lib/functools.py
+++ b/Lib/functools.py
@@ -500,10 +500,10 @@
     if maxsize == 0:
 
         def wrapper(*args, **kwds):
-            # No caching -- just a statistics update after a successful call
+            # No caching -- just a statistics update
             nonlocal misses
-            result = user_function(*args, **kwds)
             misses += 1
+            result = user_function(*args, **kwds)
             return result
 
     elif maxsize is None:
@@ -516,9 +516,9 @@
             if result is not sentinel:
                 hits += 1
                 return result
+            misses += 1
             result = user_function(*args, **kwds)
             cache[key] = result
-            misses += 1
             return result
 
     else: