Ugarit Ebla on 8 Aug 2008 09:11:19 -0700

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[PLUG] wanted to share with this

I wanted to share this cool script with you.  It's a php script which 
puts google's webpage on the localhost's memory and is retrieved from 
memory instead of the harddrive.  I have set the memory to expire after 
7 seconds.

You will need apache/php/memcached service and have it started and php's 
memcached library.

$id can be anything not just a URI, a local file perhaps.

If you reload you'll see that the first key is unix_t and will only 
change every seven seconds.



function fetch_foo($id) {
  $memcached = new Memcache;
  $memcached->connect('localhost', 11211) or die ("Could not connect");
  if ($value) {return $value;}


  $memcached->set($id, $value, false, $ttl);
  return $value;

Philadelphia Linux Users Group         --
Announcements -
General Discussion  --