Download the MemcachedWin32 installation program, http://code.jellycan.com/memcacheddirectly download win32's exe file, click here
1. install Memcached
1. download the Memcached Win32 installation program. Click here to download the win32's exe file from http://code.jellycan.com/memcached.
2. decompress the downloaded zip package to a directory, such as (E: \ iisweb \ memcached.exe), which should be a memcache.exe file.
3. run the CMD command prompt window. note: If your system is Windows 7, you need to run it as an administrator. And enter the memcache.exe directory. Run the following command to install the SDK.
Memcached-d install
4. start the memcached service.
Memcached-d start
5. run the following command to check whether memcached is successfully installed and running.
Wmic process get description, executablepath | findstr memcached.exe
If your installation is successful, memcache.exe and its complete installation path will be displayed. For example
II. install PHP Memcache extension (php_memcache.dll)
1. if your PHP extension directory does not have the dynamic link library file php_memcache.dll, click here to download the correct version.
2. decompress the file and put the php_memcache.dll file into the php extension directory. For example, if I use WampServer, My php extension directory address is E: \ wamp \ bin \ php \ php5.3.3 \ ext.
3. edit php. ini and add the following line of code to the php. ini file.
Extension = php_memcache.dll
If you use WampServer, you can restart all services through the WampServer control menu. If it is iis, restart iis. Now, the Memcached extension has been installed. Now we can use an example in the php Manual to test whether php can use the Memcached service correctly. The test code is as follows:
-
- $ Memcache = new Memcache;
- $ Memcache-> connect ('localhost', 11211) or die ("cocould not connect ");
- $ Version = $ memcache-> getVersion ();
- Echo "Server's version:". $ version ."
\ N ";
- $ Tmp_object = new stdClass;
- $ Tmp_object-> str_attr = 'test ';
- $ Tmp_object-> int_attr = 123;
- $ Memcache-> set ('key', $ tmp_object, false, 10) or die ("Failed to save data at the server ");
- Echo "Store data in the cache (data will expire in 10 seconds)
\ N ";
- $ Get_result = $ memcache-> get ('key ');
- Echo "Data from the cache:
\ N ";
- Var_dump ($ get_result );
The results are as follows: (php can work with memcached)