---
title: "💭 DiskCache API Reference — DiskCache 5.6.1 documentation"
description: "!https://grantjenks.com/docs/diskcache/api.html#diskcache.Cache.peekitem"
date: 2024-07-03
published: true
tags:
  - python
  - thought
template: link
---


![https://grantjenks.com/docs/diskcache/api.html#diskcache.Cache.peekitem](/static/https://grantjenks.com/docs/diskcache/api.html#diskcache.Cache.peekitem)

diskcache has a peekitem method that allows you to lookup the expire_time of a cached item without changing it.  I recently used this to implement debounce for fastapi background tasks with multiple workers running.  since all the workers I care about are on the same machine, but running in different processes diskcache was a great option.  All workers have access to the same disk, but not the same variables in memory.

!!! note

    This post is a <a href="/thoughts/" class="wikilink" data-title="Thoughts" data-description="These are generally my thoughts on a web page or some sort of url, except a rare few don&#39;t have a link. These are dual published off of my..." data-date="2024-04-01">thought</a>. It's a short note that I make
    about someone else's content online <a href="/tags/thoughts/" class="hashtag-tag" data-tag="thoughts" data-count=2 data-reading-time=3 data-reading-time-text="3 minutes">#thoughts</a>
