Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 773
Ardling Avatar asked Oct 16 '25 03:10

Ardling


1 Answers

diskcache does exactly what you are looking for!

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

like image 150
Thamme Gowda Avatar answered Oct 18 '25 17:10

Thamme Gowda



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!