Python in-memory cache with time to live

后端 未结 8 1554
后悔当初
后悔当初 2020-12-04 23:24

I have multiple threads running the same process that need to be able to to notify each other that something should not be worked on for the next n seconds its not the end o

8条回答
  •  余生分开走
    2020-12-05 00:06

    You can use the expiringdict module:

    The core of the library is ExpiringDict class which is an ordered dictionary with auto-expiring values for caching purposes.

    In the description they do not talk about multithreading, so in order not to mess up, use a Lock.

提交回复
热议问题