rubyrubygems

What is the appropriate directory of permanent cache files wrote within rubygems (like unix's /var)?


I am developing a rubygem, which bundle a simple CLI.

The CLI will make a web server request and cache part of its response to a text file.

But, in development, I couldn't find appropriate place to store the response cache (I did some google search). I simply placed it in the "var" directory on gem's root. But I don't think gem's root is a good place for cache files.

tmpdir is good for temporary cache files, but I want to store cache permanently.

Are there any better practice on directory path for such cache files?


Solution

  • As you probably do not want users to share cached content (and because of other security concerns), I would put it in /home/$USER/.$GEMNAME/cache (e.g. /home/yukihr/.awesomecli/cache). I do not know nothing about Windows or Mac OS, but I am sure there is a clean, portable way to access the user's home directory and place a hidden folder there.