Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
At the risk of coming in a little late, I'm pretty much doing the exact same thing you want, with the addition of also using a relational backend.

It goes something like this:

  1. Check the cache for the information
  2. If it doesnt exist in the cache, get it from the database and put it in the cache
  3. If it does, get it from the cache and serve it

The only thing you have to worry about is tuning the expiry time of your cache for optimal performance. I like the previously mentioned idea of serving everything up from the RAM disk, this will also increase your performance.

If you've built your site to generate the pages dynamically, it really is only about 6 extra lines of code to cache it all:

my $cache = Cache::FileCache->new(); my $retcache = get('tvgid'); if (! defined $retcache) { # Build your page # cache content expiry $cache->set('tvgid', $page, "5 minutes"); } else { # Return your page }

Too easy.. :-)

You infer from the OP performance is a concern to you, keep in mind there are many, many ways to optimise your code, from regex fiddling to algorithm design to OS tuning to building your own webserver, to application design.

Make sure you benchmark your code as well as RW response time to make sure you can quantify your "optimisations"


In reply to Re: quickest way to access cached data? by Ryszard
in thread quickest way to access cached data? 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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2024-04-16 19:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found