@@ -193,6 +193,8 @@ The :meth:`pop <diskcache.Cache.pop>` operation is atomic and using :meth:`incr
193
193
statistics in long-running systems. Unlike :meth: `get <diskcache.Cache.get> `
194
194
the `read ` argument is not supported.
195
195
196
+ .. _tutorial-culling :
197
+
196
198
Another four methods remove items from the cache::
197
199
198
200
>>> cache.clear()
@@ -645,22 +647,27 @@ accessible at :data:`diskcache.DEFAULT_SETTINGS`.
645
647
Eviction Policies
646
648
-----------------
647
649
648
- :doc: `DiskCache <index >` supports three eviction policies each with different
650
+ :doc: `DiskCache <index >` supports four eviction policies each with different
649
651
tradeoffs for accessing and storing items.
650
652
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
658
660
field is updated. This makes every access into a read and write which slows
659
661
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.
664
671
665
672
All clients accessing the cache are expected to use the same eviction
666
673
policy. The policy can be set during initialization using a keyword argument.
0 commit comments