Thread: help please
View Single Post
  #4  
Old 5th November 2008, 14:50
johnake's Avatar
johnake johnake is offline
Senior Member
 
Join Date: Dec 2007
Posts: 52
Default
Tortuga it is most likely you use a windows server. Memcached was in fact built with Linux in mind (and I don't blame them :). But every problem has a workaround... somehow. So here it is:

1. Download the Win32 memcache daemon from here. (I think this dude compiled it from the memcached source and modified it for Windows users).
2. Now you have to install memcache as a standalone service:
a)Unzip and copy the binaries to your desired directory (eg. c:\memcached) [you should see: memcached.exe and msvcr71.dll]
b)Install the service using the command: c:\memcached\memcached.exe -d install from the command line
c)Start the server from the Microsoft Management Console or by running one of the following commands: c:\memcached\memcached.exe -d start, or net start "memcached Server"
3.Now you have to test it to see if everything's allright:
test.php
PHP Code:

<?php
    $memcache 
= new Memcache;
    
$memcache->connect("localhost",11211);

    echo 
"Server's version: " $memcache->getVersion() . "<br />\n";

    
$tmp_object = new stdClass;
    
$tmp_object->str_attr "test";
    
$tmp_object->int_attr 123;

    
$memcache->set("key",$tmp_object,false,10);
    echo 
"Store data in the cache (data will expire in 10 seconds)<br />\n";

    echo 
"Data from the cache:<br />\n";
    
var_dump($memcache->get("key"));

?>
That ain't suppose to output anny errors of any kind :).

If you wanna increase the cache size from 64mb (which is default) to say 256mb, go to regedit to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servic es\memcached Server, find the ImagePath entry and change it to somethin' like this:
“C:\memcached\memcached.exe” -d runservice -m 256
Now when you restart the service, memcache will run with 256mb of memory.

Cheers!
__________________
PHP Code:
class mySelf extends World
   
{
       public 
$health;
       private 
$friends;
       protected 
$love;
  
   public function 
__construct()
  {
       
$this->health 100;
       
$this->friends 2;
       
$this->love true;
  }
  protected function 
__love()
  { 
      
//has a bug... for the moment...
      //will fix it later.. until then:
      
sleep(15*365*24*3600);
  }

Reply With Quote
The Following User Says Thank You to johnake For This Useful Post:
turtuga (10th November 2008)