Neaten-up a bit.

This commit is contained in:
Raymond Hettinger 2010-11-30 07:13:04 +00:00
parent 7921b9f210
commit 5e20bab422
3 changed files with 12 additions and 15 deletions

View file

@ -72,10 +72,10 @@ The :mod:`functools` module defines the following functions:
A `LRU (least recently used) cache
<http://en.wikipedia.org/wiki/Cache_algorithms#Least_Recently_Used>`_
is indicated when the pattern of calls changes over time, such as
when more recent calls are the best predictors of upcoming calls
works best when more recent calls are the best predictors of upcoming calls
(for example, the most popular articles on a news server tend to
change every day).
change each day). The cache's size limit assurs that caching does not
grow without bound on long-running processes such as web servers.
.. versionadded:: 3.2

View file

@ -332,15 +332,13 @@ New, Improved, and Deprecated Modules
c.execute('SELECT phonenumber FROM phonelist WHERE name=?', (name,))
return c.fetchone()[0]
XXX: update for Issue 10586 changes to cache statistics API
To help with choosing an effective cache size, the wrapped function is
instrumented with two attributes *cache_hits* and *cache_misses*:
instrumented with info function:
>>> for name in user_requests:
... get_phone_number(name)
>>> print(get_phone_number.cache_hits, get_phone_number.cache_misses)
4805 980
>>> get_phone_number.cache_info()
CacheInfo(maxsize=300, size=300, hits=4805, misses=980)
If the phonelist table gets updated, the outdated contents of the cache can be
cleared with: