Coder Profile - Show off your skills, get a coder profile.
 
 
 
How to use Memcache on Windows
Web Development
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
CODE: Copy / Restore  ::  Remove Scroll Bars
  1. $memcache = new Memcache();
  2. $memcache->connect('localhost', 11211);
  3. $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).
CODE: Copy / Restore  ::  Remove Scroll Bars
  1. $memcache = new Memcache();
  2. $memcache->connect('localhost', 11211);
  3. print $memcache->get('name');
And you will see that my name is still there!

It's quite simple really. You use add() to add new values to memory where they are stored... and you use get() to retrieve a value from memory. Remember that the values are kept in memory even after the .php script finishes executing and the memory is SHARED between other .php scripts.

Kind regards,
Scott


Posted By VBAssassin
Please login to rate coding articles.

Click here to register a free account with us.
Comments
Please login to post comments.
Page 1 of 1
More Articles By This Author
How to use Memcache on Windows
PHP Sessions = Member Database Cache
Speed Up Delivery of your JavaScript Libraries
AJAX - When to use it?
When to use OOP in PHP
Preventing raw PHP leaks on Apache
What makes a good PHP programmer?
Recently Posted "Web Development" Articles
Website Optimization
How to use Memcache on Windows
PHP Sessions = Member Database Cache
Speed Up Delivery of your JavaScript Libraries
A cool tool ^^
AJAX - When to use it?
Introduction To PHP
[PHP] XML
HTML vs XHTML
[PHP] XML: HTML DOM Basics
Recently Rated "Web Development" Articles
PHP Sessions = Member Database Cache
Website Optimization
How to use Memcache on Windows
Preventing raw PHP leaks on Apache
When to use OOP in PHP
AJAX - When to use it?
Speed Up Delivery of your JavaScript Libraries
[PHP] XML
A cool tool ^^
HTML vs XHTML
source codes Categories articles
Browse All
Business & E-Commerce (1)
Databases (1)
Design & Creativity (1)
Internet & Web Sites (1)
Life In General (2)
Networking (1)
Operating Systems (4)
Other (2)
Programming (51)
Security (10)
Software Development (5)
Standards (1)
Web Development (15)
search Search Inside
Web Development
 
 
Latest News About Coder Profile
Coder Profile Poll
What is the next application you would like to be added to your profiles?

Books
Coding Challenges
Project Management
Blog
Tutorials


please login to cast your vote
and see the results of this poll
Latest Coder Profile Changes
Coder Profile was last updated
5 Days Ago
Official Blog :: Make A Donation :: Credits :: Contact Me
Terms & Conditions :: Privacy Policy :: Documents :: Wallpapers
Version 1.46.00
Copyright © 2007 - 2008, Scott Thompson, All Rights Reserved