About Sitellite       Screenshots       Downloads       Forge      Documentation       Community       Support

You are here: Home / Documentation / Caching for Better Performance

Caching for Better Performance

Query-level caching

Let's look at a simple PHP script that retrieves the newest 10 news stories from a web site.  Not a database-intensive query, but it will suffice as an example for our purposes.
<?php
/* retrieve the top 10 headlines */
$q = db_query (
  'select id, title from sitellite_news
order by date desc limit 10'
);
$res = array ();
if ($q->execute ()) {
  while ($row = $q->fetch ()) {
    $res[] = $row;
  }
  $q->free ();
}
/* display the headlines as a bulleted list */
echo template_simple (
  '<h2>{intl Latest Headlines}</h2>
  <ul>
  {loop obj}
    <li>
      <a href="{site/prefix}/index/tutorials-story-action/story.{loop/id}">
{loop/title}
</a>
    </li>
  {end loop}
  </ul>',
  $res
);
?>
You're going to love how easy adding query caching to this script is.  Check this out:
<?php

/* retrieve the top 10 headlines */
$q = db_query (
  'select id, title from sitellite_news
order by date desc limit 10',
  true
);

?>
That's all there is to it.  Simply pass a second boolean parameter to db_query() and if query caching is configured in your config.ini.php, it will happen automatically for your query.  How much easier could it get?

Conclusion

Sitellite offers simple but highly effective solutions to improving the performance of web applications at every level.  The only thing we can't solve for you is choosing the right solution for your project's needs. :)

Page 1: Caching in General
Page 2: Caching in Sitellite
Page 3: Partial-page caching
Page 4: Query-level caching

All Tutorials

Members

Note: You can use your SitelliteForge.com account here and vice versa.

Username

Password

Forgot your password?

Not a member? Click here to register

Sitellite 5 Beta


Copyright © 2008, SIMIAN systems Inc.
All rights reserved. Privacy policy
Some of the icons on this site were created by the Gnome Project.