It scares me to think that with your current implementation, there is nothing preventing the cache from growing to the total size of your website (every page will become cached eventually). Multiply that by the potential for multiple instances of the same caches, and you could end up with a potentially huge memory footprint. This is not a scalable approach. Care and caution could be exercised such that your cache will never grow beyond a predetermined size... a smarter caching method. ...and at the same time, you could find a way of dealing with multiple instances.

I would not be surprised if caching could be used to gain some performance improvements. But I have to wonder if the caching should, perhaps, be a layer built onto the database side of things rather than the CGI script. Let a layer between the database and the CGI script deal with the nitty gritty task of calculating which pages are most popular, and limiting the cache size. Doing it this way could make it easier to deal with multiple instances also, since there need only be one instance of the database caching layer.


Dave


In reply to Re: Repetitive File I/O vs. Memory Caching by davido
in thread Repetitive File I/O vs. Memory Caching by Anonymous Monk

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.