Ignoring the specific details, I have a more general concern - it seems like you want a DWIM (do what I mean) kind of solution. You want your CGI to cache values from a DB, so that you don't need to go & retrieve them every time, yet the data from the DB may change at what seems to be arbitrary times.

As we've seen in the above posts, there are a number of ways to keep this data resident in the live CGI without hitting the DB, but how do you plan to handle updates? When does the CGI know to query the DB for the new information? Is this information that should really be in a database? Perhaps this is something that should be in a config file that's read on startup?

There's nothing wrong with trying to minimize the amount of DB activity - in fact there's a lot right with that concern. That being said, DB handles can be cached and simple queries in a well-configure DB return fast. Don't create a new problem to solve one that might not be a big issue.


In reply to Re: CGI Application and global variables (from a database) by swngnmonk
in thread CGI Application and global variables (from a database) by tmaciak

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.