WindowsÏÂMemcached°²×°¼°Java¿Í»§¶Ëµ÷ÓÃ
WindowsϵÄMemcache°²×°£º
1. ÏÂÔØmemcacheµÄwindowsÎȶ¨°æ£¬½âѹ·Åij¸öÅÌÏÂÃ棬±ÈÈçÔÚc:\memcached
2. ÔÚÖնˣ¨Ò²¼´cmdÃüÁî½çÃ棩ÏÂÊäÈë ‘c:\memcached\memcached.exe -d install’ °²×°
3. ÔÙÊäÈ룺 ‘c:\memcached\memcached.exe -d start’ Æô¶¯¡£NOTE: ÒÔºómemcached½«×÷ΪwindowsµÄÒ»¸ö·þÎñÿ´Î¿ª»úʱ×Ô¶¯Æô¶¯¡£ÕâÑù·þÎñÆ÷¶ËÒѾ°²×°Íê±ÏÁË¡£
4.ÏÂÔØphp_memcache.dll£¬Çë×Ô¼º²éÕÒ¶ÔÓ¦µÄphp°æ±¾µÄÎļþ
5. ÔÚC:\winnt\php.ini ¼ÓÈëÒ»ÐÐ ‘extension=php_memcache.dll’
6.ÖØÐÂÆô¶¯Apache£¬È»ºó²é¿´Ò»ÏÂphpinfo£¬Èç¹ûÓÐmemcache£¬ÄÇô¾Í˵Ã÷°²×°³É¹¦£¡
memcachedµÄ»ù±¾ÉèÖãº
-p ¼àÌýµÄ¶Ë¿Ú
-l Á¬½ÓµÄIPµØÖ·, ĬÈÏÊDZ¾»ú
-d start Æô¶¯memcached·þÎñ
-d restart ÖØÆðmemcached·þÎñ
-d stop|shutdown ¹Ø±ÕÕýÔÚÔËÐеÄmemcached·þÎñ
-d install °²×°memcached·þÎñ
-d uninstall жÔØmemcached·þÎñ
-u ÒÔµÄÉí·ÝÔËÐÐ (½öÔÚÒÔrootÔËÐеÄʱºòÓÐЧ)
-m ×î´óÄÚ´æʹÓ㬵¥Î»MB¡£Ä¬ÈÏ64MB
-M ÄÚ´æºÄ¾¡Ê±·µ»Ø´íÎ󣬶ø²»ÊÇɾ³ýÏî
-c ×î´óͬʱÁ¬½ÓÊý£¬Ä¬ÈÏÊÇ1024
-f ¿é´óСÔö³¤Òò×Ó£¬Ä¬ÈÏÊÇ1.25
-n ×îС·ÖÅä¿Õ¼ä£¬key+value+flagsĬÈÏÊÇ48
-h ÏÔʾ°ïÖú
JAVA¿Í»§¶ËµÄ±àд:
import java.util.Date;
import com.danga.MemCached.*;
public class BasicTest {
private static final String POOL_NAME="test_pool";
protected static MemCachedClient mcc;
static {
//ÉèÖûº´æ·þÎñÆ÷ÁÐ±í£¬µ±Ê¹Ó÷ֲ¼Ê½»º´æµÄʱ£¬¿ÉÒÔÖ¸¶¨¶à¸ö»º´æ·þÎñÆ÷
String[] servers =
{
"127.0.0.1:11211"
};
//Óë·þÎñÆ÷ÁбíÖжÔÓ¦µÄ¸÷·þÎñÆ÷µÄȨÖØ
Integer[] weights = {3};
//´´½¨SockedÁ¬½Ó³Ø
SockIOPool pool = SockIOPool.getInstance(POOL_NAME);
//ÏòÁ¬½Ó³ØÉ趨·þÎñÆ÷ºÍȨÖØ
pool.setServers( servers );
pool.setWeights( weights );
//Á¬½Ó³Ø²ÎÊý
pool.setInitConn( 5 );
pool.setMinConn( 5 );
pool.setMaxConn( 250 );
pool.setMaxIdle( 1000 * 60 * 60 * 6 );
// set the sleep for the maint thread
// it will wake up every x seconds and
// maintain the pool size
pool.setMaintSleep( 30 );
// set some TCP settings
// disable nagle
// set the read timeout to 3 secs
// and don't set a connect timeout
pool.setNagl
Ïà¹ØÎĵµ£º
java_home
C:\Program Files\Java\jdk1.6.0_16
Path
%java_home%\bin;%java_home%\lib;
classpath
%java_home%\lib\dt.jar;%java_home%\lib\tools.jar;.;
java_home
C:\Program Files\Java\jdk1.6.0_16
Path
%SystemRoot%\system32;%java_home%\bin;%java_home%\lib;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\P ......
»·¾³: JDK 5.0 + Tomcat 5.5.4
JDK°²×°Â·¾¶: D:\Java\jdk1.5.0_01
Tomcat°²×°Â·¾¶:D:\Tomcat 5.5
ÉèÖû·¾³±äÁ¿(¿ØÖÆÃæ°å->ϵͳ->¸ß¼¶):
java_home=D:\Java\jdk1.5.0_01
path=%JAVA_HOME%\bin
classpath=.;D:\Java\jdk1.5.0_01\lib\dt.jar;D:\Java\jdk1.5.0_01\lib\tools.jar;D:\Tomcat 5.5\common\lib\se ......
Java ÊÇÒÔÀࣨclass£©µÄÐÎʽÀ´×éÖ¯³ÌÐò£¬²¢ÇÒ»¹Ó²ÐԹ涨£¬ËùÓÐÀàµÄµÄ¸ù½Úµã¶¼ÊÇObjectÀ࣬ÆäÓàµÄ¶¼ÊÇÆä×ÓÀà¡£
Java½öÖ§³Öµ¥¼Ì³Ð£¬¼´Ò»¸öÀàÖ»ÄÜÓÐÒ»¸ö¸¸Àà¡£
Java²»µ¥ÊÇÒ»¸öÃæÏò¶ÔÏóµÄ±à³ÌÓïÑÔ£¬ ³ýÁËÖ§³Ö¶ÔÏóÊý¾ÝÀàÐÍÍ⣬»¹Ö§³ÖһЩ»ù´¡Êý¾ÝÀàÐÍ£¬ÈçÕûÐÍ¡¢ÊµÐÍ¡¢×Ö·ûÐͺͲ¼¶ûÀàÐ͵ȡ£
JavaÓïÑÔµÄÓ¦ÓóÌÐò±à³ ......
JavaÓïÑÔµÄÊäÈëÊä³ö¹¦ÄÜÊÇÊ®·ÖÇ¿´ó¶øÁé»îµÄ£¬ÃÀÖв»×ãµÄÊÇ¿´ÉÏÈ¥ÊäÈëÊä³öµÄ´úÂë²¢²»ÊǺܼò½à£¬ÒòΪÄãÍùÍùÐèÒª°ü×°Ðí¶à²»Í¬µÄ¶ÔÏó¡£ÔÚJavaÀà¿âÖУ¬IO²¿·ÖµÄÄÚÈÝÊǺÜÅÓ´óµÄ£¬ÒòΪËüÉæ¼°µÄÁìÓòºÜ¹ã·º:±ê×¼ÊäÈëÊä³ö£¬ÎļþµÄ²Ù×÷£¬ÍøÂçÉϵÄÊý¾ÝÁ÷£¬×Ö·û´®Á÷£¬¶ÔÏóÁ÷£¬zipÎļþÁ÷....±¾ÎĵÄÄ¿µÄÊÇΪ´ó¼Ò×öÒ»¸ö¼òÒªµÄ½éÉÜ¡£ Á÷ÊÇÒ»¸ ......
µÚÒ»ÖÖ·½Ê½²ÉÓÃjni£º
Java²»ÊÇÍêÃÀµÄ£¬JavaµÄ²»×ã³ýÁËÌåÏÖÔÚÔËÐÐËÙ¶ÈÉÏÒª±È´«Í³µÄC++ÂýÐí¶àÖ®Í⣬JavaÎÞ·¨Ö±½Ó·ÃÎʵ½²Ù×÷ϵͳµ×²ã£¨ÈçϵͳӲ¼þµÈ)£¬Îª´ËJavaʹÓÃnative·½·¨À´À©Õ¹Java³ÌÐòµÄ¹¦ÄÜ¡£
¡¡¡¡¿ÉÒÔ½«native·½·¨±È×÷Java³ÌÐòͬ£Ã³ÌÐòµÄ½Ó¿Ú£¬ÆäʵÏÖ²½Ö裺
1.ÔÚJavaÖÐÉùÃ÷native()·½·¨£¬È»ºó±àÒ룻ÀýÈ磺¡¡public ......