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>");
    }

    相关文章:

    • 2022-12-23
    • 2022-12-23
    • 2022-01-23
    • 2021-09-16
    • 2021-11-08
    • 2021-05-30
    猜你喜欢
    • 2022-02-13
    • 2022-12-23
    • 2021-10-11
    • 2022-03-02
    • 2022-12-23
    相关资源
    相似解决方案