Persistent multiprocess shared cache in Python with stdlib or minimal dependencies

前端 未结 3 577
有刺的猬
有刺的猬 2021-02-06 10:00

I just tried a Python shelve module as the persistent cache for data fetched from the external service. The complete example is here.

I was wondering what would the best

3条回答
  •  忘了有多久
    2021-02-06 10:47

    I'd say you'd want to use some existing caching library, dogpile.cache comes to mind, it has many features already, and you can easily plug in the backends you might need.

    dogpile.cache documentation tells the following:

    This “get-or-create” pattern is the entire key to the “Dogpile” system, which coordinates a single value creation operation among many concurrent get operations for a particular key, eliminating the issue of an expired value being redundantly re-generated by many workers simultaneously.

提交回复
热议问题