in reply to Re: Where to save module data
in thread Where to save module data

if you'll permit me to chip in with the results of my experience...

I am always eager to hear hippo experience nuggets!

In Perl we are fortunate indeed to have a very high-quality but generic and flexible cache module available to use in the shape of CHI and it would be hard to praise it too highly.

Thank you hippo - until now, this module has been unknown to me.

Briefly looking at it, I can immediately see its value and will try it out with a simple use case...

Replies are listed 'Best First'.
Re^3: Where to save module data
by ysth (Canon) on Oct 09, 2024 at 16:39 UTC

    CHI does look like the way to go. But its File driver defaults to /tmp/chi-driver-file (or OS equivalent), and it sounds to me like your data would more appropriately be in /var/cache/your-module-name.

    Filesystem Hierarchy Standard:
    /var/cache is intended for cached data from applications. Such data is locally generated as a result of time-consuming I/O or calculation. The application must be able to regenerate or restore the data. Unlike /var/spool, the cached files can be deleted without data loss. The data must remain valid between invocations of the application and rebooting the system. Files located under /var/cache may be expired in an application specific manner, by the system administrator, or both. The application must always be able to recover from manual deletion of these files (generally because of a disk space shortage). No other requirements are made on the data format of the cache directories.
    You'd want to specify a location for Windows, too. A little googling didn't find any close equivalent to /var/cache for non-FHS systems, so if /var/cache doesn't exist, you'd likely just want to use something under File::Spec->tmpdir or let CHI default.
    --
    A math joke: r = | |csc(θ)|+|sec(θ)| |-| |csc(θ)|-|sec(θ)| |
Re^3: Where to save module data
by Intrepid (Curate) on Oct 19, 2024 at 22:32 UTC

    I just thought I'd add a comment on CHI. I hadn't ever heard of it
    either and it seems like a valuable module to know about if you need to
    store/cache data. Happily, I report that it installs without drama on
    cygwinPerl; lots of dependencies though. IMHO however, this is generally
    a good thing. It shows that the author has thought carefully about
    her/his code and researched thoroughly.

    Oct 19, 2024 at 22:30 UTC
    Examine what is said, not who speaks.
    Love the truth but pardon error.
    Silence betokens consent.
    In the absence of evidence, opinion is indistinguishable from prejudice.