简体   繁体   中英

How to save data in disk cache properly?

I want to save data between runs of my python application (data should be the same for different users). The best way I have found was save it in file on disk. Directory /var/cache/my_package looks good for this purposes, but I faced a few difficulty:

  1. how to create this folder during the installation
  2. how to set owner and access rules
  3. how to access cache files without hardcoding absolute path

I have found data_file option in setuptools but it can't help with points 2 and 3.

How about not reinventing diskcache.

Check out examples here: http://www.grantjenks.com/docs/diskcache/tutorial.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM