示例#1
0
        static void Main(string[] args)
        {
            log4net.Config.XmlConfigurator.Configure();

            // or just initialize the client from code
            var nscc = new MembaseClientConfiguration();

            nscc.SocketPool.ReceiveTimeout = new TimeSpan(0, 0, 2);
            nscc.SocketPool.DeadTimeout = new TimeSpan(0, 0, 10);

            nscc.Urls.Add(new Uri("http://192.168.2.160:8091/pools/default"));
            //nscc.Urls.Add(new Uri("http://192.168.2.162:8091/pools/default"));
            nscc.Credentials = new NetworkCredential("A", "11111111");
            nscc.PerformanceMonitorFactory = new Membase.Configuration.DefaultPerformanceMonitorFactory();
            //nscc.BucketPassword = "******";

            ThreadPool.QueueUserWorkItem(o => StressTest(new MembaseClient(nscc, "default"), "TesT_A_"));
            ThreadPool.QueueUserWorkItem(o => StressTest(new MembaseClient("content"), "TesT_B_"));

            //ThreadPool.QueueUserWorkItem(o => StressTest(new MembaseClient(nscc, "default"), "TesT_B_"));
            //ThreadPool.QueueUserWorkItem(o => StressTest(new MembaseClient(nscc, "default"), "TesT_C_"));
            //ThreadPool.QueueUserWorkItem(o => StressTest(new MembaseClient(nscc, "default"), "TesT_D_"));

            Console.ReadLine();

            return;

            var mcc = new MemcachedClientConfiguration();
            mcc.AddServer("192.168.2.200:11211");
            mcc.AddServer("192.168.2.202:11211");

            mcc.SocketPool.ReceiveTimeout = new TimeSpan(0, 0, 4);
            mcc.SocketPool.ConnectionTimeout = new TimeSpan(0, 0, 4);
            mcc.SocketPool.DeadTimeout = new TimeSpan(0, 0, 10);

            StressTest(new MemcachedClient(mcc), "TesT_");

            return;

            var nc = new MembaseClient(nscc, "content");

            var stats1 = nc.Stats("slabs");
            foreach (var kvp in stats1.GetRaw("curr_connections"))
                Console.WriteLine("{0} -> {1}", kvp.Key, kvp.Value);

            var nc2 = new MembaseClient(nscc, "content");

            var stats2 = nc2.Stats();
            foreach (var kvp in stats2.GetRaw("curr_connections"))
                Console.WriteLine("{0} -> {1}", kvp.Key, kvp.Value);
        }
示例#2
0
        static void Main(string[] args)
        {
            log4net.Config.XmlConfigurator.Configure();

            // or just initialize the client from code
            var nscc = new MembaseClientConfiguration();

            nscc.SocketPool.ReceiveTimeout = new TimeSpan(0, 0, 2);
            nscc.SocketPool.DeadTimeout = new TimeSpan(0, 0, 10);

            nscc.Urls.Add(new Uri("http://192.168.2.160:8091/pools/default"));
            //nscc.Urls.Add(new Uri("http://192.168.2.162:8091/pools/default"));
            //nscc.Credentials = new NetworkCredential("A", "11111111");
            //nscc.Bucket = "content";
            //nscc.BucketPassword = "******";

            var client = new MembaseClient(nscc);
            Console.WriteLine("Store = " + client.Store(StoreMode.Set, "4q", 1, new TimeSpan(0, 0, 4)));

            Console.WriteLine("Setting expiration to the far future.");
            //Console.ReadLine();

            client.Touch("4q", DateTime.Now.AddDays(1));

            Console.WriteLine("Wait for 4 sec.");
            Console.ReadLine();

            Console.WriteLine(client.Get("4q") ?? "<null>");

            //new MembaseClient(nscc, "data", "data").Store(StoreMode.Set, "q4", 2);
            //new MembaseClient(nscc, "feedback", null).Store(StoreMode.Set, "q4", 2);

            Console.ReadLine();

            //nscc.PerformanceMonitorFactory = new Membase.Configuration.DefaultPerformanceMonitorFactory();
            //nscc.BucketPassword = "******";

            //ThreadPool.QueueUserWorkItem(o => StressTest(new MembaseClient(nscc), "TesT_A_"));
            //ThreadPool.QueueUserWorkItem(o => StressTest(new MembaseClient("content", "content"), "TesT_B_"));

            //ThreadPool.QueueUserWorkItem(o => StressTest(new MembaseClient(nscc, "default"), "TesT_B_"));
            //ThreadPool.QueueUserWorkItem(o => StressTest(new MembaseClient(nscc, "default"), "TesT_C_"));
            //ThreadPool.QueueUserWorkItem(o => StressTest(new MembaseClient(nscc, "default"), "TesT_D_"));

            Console.ReadLine();

            return;

            var mcc = new MemcachedClientConfiguration();
            mcc.AddServer("192.168.2.200:11211");
            mcc.AddServer("192.168.2.202:11211");

            mcc.SocketPool.ReceiveTimeout = new TimeSpan(0, 0, 4);
            mcc.SocketPool.ConnectionTimeout = new TimeSpan(0, 0, 4);
            mcc.SocketPool.DeadTimeout = new TimeSpan(0, 0, 10);

            StressTest(new MemcachedClient(mcc), "TesT_");

            return;

            var nc = new MembaseClient(nscc, "content", "content");

            var stats1 = nc.Stats("slabs");
            foreach (var kvp in stats1.GetRaw("curr_connections"))
                Console.WriteLine("{0} -> {1}", kvp.Key, kvp.Value);

            var nc2 = new MembaseClient(nscc, "content", "content");

            var stats2 = nc2.Stats();
            foreach (var kvp in stats2.GetRaw("curr_connections"))
                Console.WriteLine("{0} -> {1}", kvp.Key, kvp.Value);
        }