Just looking for a little advice before I try to re-implement the wheel.

I'm looking for an interface/module/method that will help me manage a few hundred of potentially large files 1M->200GB as a "cache".These files are very expensive computationally to create but can easily be re-made so we're looking to cache results on the filesystem. If they get destroyed because the cache had to purge them then we'll just re-create them.

In a nutshell I want to tie a set of files to a caching algorithm.

I've looked into CHI, Cache::Cache and Cache::File but they seem to be missing a few of my requirements.
1. I want to tell the cache what the object size is and have it free up that space for me if possible.
2. I want to store the object myself with my own filename. Processes that cant talk to perl need to be able to find the files by their filename.
3. I don't care about cache speed. Get/Set requests will be measured in the dozens per hour.

I really want is a size-aware cache where I can say:

1. I want to store a 100GB file called Foofile.dat in the cache. Is there room?
2. No? Then please make 100GB for me by removing files according to LRU or some other cache policy.
3. Is there room now? Then allocate a 100GB block of space in the cache where Foofile.dat will go.
This 100GB is gone and cant be used by another process unless its purged.
4. Kickoff other process that writes Foofile.dat

later....some other process wants the file

1. Is Foofile.dat in the cache? Either ask in perl or look in the cache directory with ls or stat..etc.
2. Yes? Ok great. I'll read Foofile.dat myself.
3. No? Awww....handle fail condition.

Does such a thing already exist or shall I have to make one? I haven't poked too deep but I may be able to extend one of the cache modules in CPAN.

Update: It looks like writing a CHI::Driver is the way to go. After looking at the source to CHI::Driver::File it seems simple enough and doable and I'll probably just take CHI::Driver::File as a base and fork it for my purposes.


In reply to Managing a "cache" of files by bot403

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.