@@ -314,6 +314,36 @@ keys will be serialized which is likely to have a meaningless sorted order.
314314If only the first or last item in insertion order is desired then
315315:meth: `peekitem <.Cache.peekitem> ` is more efficient than using iteration.
316316
317+ Three additional methods use the sorted ordering of keys to maintain a
318+ queue-like data structure within the cache. The :meth: `push <.Cache.push> `,
319+ :meth: `pull <.Cache.pull> `, and :meth: `peek <.Cache.peek> ` methods
320+ automatically assign the key within the cache.
321+
322+ >>> key = cache.push(' first' )
323+ >>> print (key)
324+ 500000000000000
325+ >>> cache[key]
326+ 'first'
327+ >>> _ = cache.push(' second' )
328+ >>> _ = cache.push(' zeroth' , side = ' front' )
329+ >>> _, value = cache.peek()
330+ >>> value
331+ 'zeroth'
332+ >>> key, value = cache.pull()
333+ >>> print (key)
334+ 499999999999999
335+ >>> value
336+ 'zeroth'
337+
338+ The `side ` parameter supports access to either the ``'front' `` or ``'back' `` of
339+ the cache. In addition, the `prefix ` parameter can be used to maintain multiple
340+ queue-like data structures within a single cache. When prefix is ``None ``,
341+ integer keys are used. Otherwise, string keys are used in the format
342+ “prefix-integer”. Integer starts at 500 trillion. Like :meth: `set <.Cache.set> `
343+ and :meth: `get <.Cache.get> `, methods :meth: `push <.Cache.push> `, :meth: `pull
344+ <.Cache.pull> `, and :meth: `peek <.Cache.peek> ` support cache metadata like the
345+ expiration time and tag.
346+
317347Lastly, three methods support metadata about the cache. The first is
318348:meth: `volume <diskcache.Cache.volume> ` which returns the estimated total size
319349in bytes of the cache directory on disk.
0 commit comments