首页 > 系统服务 > 详细

Memcachedf——分布式缓存

时间:2016-05-05 11:03:16      阅读:236      评论:0      收藏:0      [点我收藏+]

       下载文件:https://sourceforge.net/projects/memcacheddotnet/ 

       将Commons.dll,ICSharpCode.SharpZipLib.dll,log4net.dll,Memcached.ClientLibrary.dll 等放到bin目录

       引用Memcached.ClientLibrary.dll

      程序实例:

       

using Memcached.ClientLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Memcached随练
{
    class Program
    {
        static void Main(string[] args)
        {
            //分布Memcachedf服务IP 端口
            string[] servers = { "127.0.0.1:11211", "192.168.202.128:11211" };

            //初始化池
            SockIOPool pool = SockIOPool.GetInstance();
            pool.SetServers(servers);
            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();
            //客户端实例
            MemcachedClient mc = new Memcached.ClientLibrary.MemcachedClient();
            mc.EnableCompression = false;
            mc.Add("aaa", "shit");//添加一个值
            mc.Add("bbb", "hello", DateTime.Now.AddSeconds(10));//设置过期时间
            mc.Delete("aaa");//删除指定值
            mc.Get("aaa");
            Console.WriteLine(mc.Get("bbb"));

        }
    }
}

 

Memcachedf——分布式缓存

原文:http://www.cnblogs.com/shuai7boy/p/5460963.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!