Skip to content

Commit 71d1b47

Browse files
committed
Document the "none" eviction policy in tutorial
1 parent cdc59c1 commit 71d1b47

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

docs/api.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ Index
4848
:special-members:
4949
:exclude-members: __weakref__
5050

51+
.. _constants:
52+
5153
Constants
5254
---------
5355

docs/tutorial.rst

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ The :meth:`pop <diskcache.Cache.pop>` operation is atomic and using :meth:`incr
193193
statistics in long-running systems. Unlike :meth:`get <diskcache.Cache.get>`
194194
the `read` argument is not supported.
195195

196+
.. _tutorial-culling:
197+
196198
Another four methods remove items from the cache::
197199

198200
>>> cache.clear()
@@ -645,22 +647,27 @@ accessible at :data:`diskcache.DEFAULT_SETTINGS`.
645647
Eviction Policies
646648
-----------------
647649

648-
:doc:`DiskCache <index>` supports three eviction policies each with different
650+
:doc:`DiskCache <index>` supports four eviction policies each with different
649651
tradeoffs for accessing and storing items.
650652

651-
* `Least Recently Stored` is the default. Every cache item records the time it
652-
was stored in the cache. This policy adds an index to that field. On access,
653-
no update is required. Keys are evicted starting with the oldest stored
654-
keys. As :doc:`DiskCache <index>` was intended for large caches (gigabytes)
655-
this policy usually works well enough in practice.
656-
* `Least Recently Used` is the most commonly used policy. An index is added to
657-
the access time field stored in the cache database. On every access, the
653+
* ``"least-recently-stored"`` is the default. Every cache item records the time
654+
it was stored in the cache. This policy adds an index to that field. On
655+
access, no update is required. Keys are evicted starting with the oldest
656+
stored keys. As :doc:`DiskCache <index>` was intended for large caches
657+
(gigabytes) this policy usually works well enough in practice.
658+
* ``"least-recently-used"`` is the most commonly used policy. An index is added
659+
to the access time field stored in the cache database. On every access, the
658660
field is updated. This makes every access into a read and write which slows
659661
accesses.
660-
* `Least Frequently Used` works well in some cases. An index is added to the
661-
access count field stored in the cache database. On every access, the field
662-
is incremented. Every access therefore requires writing the database which
663-
slows accesses.
662+
* ``"least-frequently-used"`` works well in some cases. An index is added to
663+
the access count field stored in the cache database. On every access, the
664+
field is incremented. Every access therefore requires writing the database
665+
which slows accesses.
666+
* ``"none"`` disables cache evictions. Caches will grow in size without
667+
bound. Cache items will still be lazily removed if they expire. The
668+
persistent data types, :class:`.Deque` and :class:`.Index`, use the
669+
``"none"`` eviction policy. For :ref:`lazy culling <tutorial-culling>` use
670+
the :ref:`cull_limit <constants>` setting instead.
664671

665672
All clients accessing the cache are expected to use the same eviction
666673
policy. The policy can be set during initialization using a keyword argument.

0 commit comments

Comments
 (0)