Windows安装Memcached

Download [memcached.exe] [gui] and [.net lib]

memcached-1.2.6-win32-bin.zip
Memcached Manager
Memcached .NET client Library 

Add reference

\trunk\clientlib\src\clientlib\bin\2.0\Release\Memcached.ClientLibrary.dll

  
    
[Serializable]
class Student
{
public int ID { get ; set ; }
public string Name { get ; set ; }
public DateTime DOB { get ; set ; }
public override string ToString()
{
return string .Format( " id:{0}, name:{1}, dob:{2} " , ID, Name, DOB);
}
}

protected void Page_Load( object sender, EventArgs e)
{
MemInit();
MemSet();
MemGet();
}

void MemInit()
{
SockIOPool pool
= SockIOPool.GetInstance();
pool.SetServers(
new [] { " 127.0.0.1:11211 " });
pool.InitConnections
= 3 ;
pool.MinConnections
= 3 ;
pool.MaxConnections
= 5 ;
pool.SocketConnectTimeout
= 1000 ;
pool.SocketTimeout
= 3000 ;
pool.MaintenanceSleep
= 30 ;
pool.Failover
= true ;
pool.Nagle
= false ;
pool.Initialize();
}

void MemSet()
{
var mc
= new MemcachedClient();
mc.Set(
" string " , " hello " );
mc.Set(
" int " , 99 );
mc.Set(
" datetime " , DateTime.Now);
mc.Set(
" person " ,
new Student { ID = 1 , Name = " Mike " , DOB = DateTime.Parse( " 1983/10/14 " ) });
}

void MemGet()
{
var mc
= new MemcachedClient();
WriteLine((
string )mc.Get( " string " ));
WriteLine((
int )mc.Get( " int " ));
WriteLine((DateTime)mc.Get(
" datetime " ));
WriteLine((Student)mc.Get(
" person " ));
}

void WriteLine( object p)
{
Response.Write(p
+ " <br> " );
}

你可能感兴趣的:(memcached)