First, I would encourage you to look at Rose::DB::Object, since this looks awfully familiar.

The caching you're describing is a pretty common practice. It does have risks, in that the data in memory is not guaranteed to reflect the database unless you grab an exclusive lock on it (e.g. SELECT...FOR UPDATE). There has been some writing on the subject in the past, since this has been the way things are done for decades. I think I once read something by Fowler about it.

The gist of it is that most programmers copy database state into memory for at least short periods of time in order to make it easier to deal with. Then they write it back out. Many millions of hours of effort have been put into making this process easier and/or hiding it from client code. You're on a similar track and you're not wrong to do it this way.


In reply to Re: not caching to object in code interface to database? by perrin
in thread not caching to object in code interface to database? by leocharre

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.