About Sitellite       Screenshots       Downloads       Forge      Documentation       Community       Support

You are here: Home / Documentation / Sitellite and memcached

Sitellite and memcached

Running memcached

Now that memcached is installed onto your server, you should be able to run the memcached server daemon, also from the Unix command-line.  For the purposes of this article, I started memcached on my server with the following command:
$ memcached -d -p 11211
This makes memcached run as a daemon, listening on port 11211.  For a list of options, try:
$ memcached -h

Installing the memcached PHP API

In the folder inc/app/myapp/lib, drop the file MemCachedClient.inc.php, which you can download from the memcached web site.  You will likely need to create the folders below inc/app yourself, as I'm trying to encourage you to work within your own app structure in Sitellite, instead of modifying existing source code.  This helps improve reusability and maintainability of your custom code.

You should also rename the file to be simply MemCachedClient.php (no ".inc").

A Simple Box

Create a new file called inc/app/myapp/boxes/latestheadlines/index.php and paste the following code into it:
<?php

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

/* 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
);

?>
Now you can create a sidebar with a box alias of "myapp/latestheadlines" to display the top 10 headlines on your web site.

Next: Adding memcached to the Mix

Page 1: Installing memcached
Page 2: Running memcached
Page 3: Adding memcached to the Mix

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.