I will quickly run you through an example of HOW to use memcache and how it works.
Download Memcache
http://jehiah.cz/projects/memcached-win32/
And load up the .exe - you should just get a blank command box appear - the server is then running on localhost:11211
Install the Memcache extensions in to PHP
If you use something like xamp or easyphp - just enable the memcache exentions (just a case of maybe uncommenting a line or ticking a box like in easyphp).
Code Example
$memcache = new Memcache();
$memcache->connect('localhost', 11211);
$memcache->add('name', 'Scott Thompson', false, 60);
Put that code in a .php page (remember to have the memcache server running). Now simply run the script and it will save my name in memory for 60 seconds! To retrieve the value from memory now put this in the script (within 60 seconds else it will expire from memory).
$memcache = new Memcache();
$memcache->connect('localhost', 11211);
print $memcache->get('name');
And yo... View In Full
Let�s go over what a session is.
Sessions
First you call session_start() which gives you a unique ID such as: dde2ds2g67xs2zxjh89s3j8923
Everything you then save to $_SESSION is saved in a file on the server such as:
$_SESSION['message'] = 'hello';
Would be saved to:
tmp/phpsess_dde2ds2g67xs2zxjh89s3j8923
and next time you call session_start(), $_SESSION['message'] will still exist and will have 'hello' in it!
Database Problem
So, you record a members total page hits on your site, and the last time they made a page hit on your site. You keep these stats up to date like this (which is executed on EVERY page hit by the member):
$time = time();
mysql_query("UPDATE `members` SET `timestamp_last_seen` = '{$time}', `hits` = `hits` + 1 WHERE `member` = 'VBAssassin' LIMIT 1;");
Now, all you�re doing is keeping track of the last time they were seen, and the total page hits they have made while logged in.
Solution
You need to keep track of your active sessions u... View In Full
Hello,
I am going to show you how to speed up delivery of you external .js files along with examples. I will use the prototype and scriptaculous javascript libraries as a benchmark which contains 8 seperate .js files.
Unoptimized .JS
Here are the results using YSlow to benchmark the speed of the JS files downloading when there is no gzip compression, no cdn, and no minification of the js code:
Response Time (ms): 4477 (all files)
File Size (kb): 248.7
4.4 seconds to download some JS files! Thats 4.4 seconds, on broadband, to wait before the page even renders!!! So lets get that optimized.
Option 1 - Optimized .JS - Using Google
http://code.google.com/apis/ajaxlibs/documentation/index.html
This is a very quick and easy way to speed up the delivery of the library files to an acceptable level. The same files, gziped with cdn (not minimized, but gzip kind of makes up for that loss)... results in the following:
Response Time (ms): 1920 (all files)
File Size (kb)... View In Full
Takes care of the hard work when creating pagination and can carry across variables between pages in the pages URL. Multiple instances of pagination can be used on a single page.
Got a site where you have affiliates and they can earn points? And you want to pick a random affiliate to show on your site? But you want an affiliate with more points to be more likely to be picked?
I'm a computer science major and getting a software engineering minor. This semester I'm taking two maths, CS, Society, Tech, and Values, and CS and Math Computer Science.