how to use memcache

Total Post:281

 1180  View(s)
Rate this:
how to use memcache
  1. Post:281

    Re: how to use memcache

    1. Install Memcached server in Windows

    The latest Memcached version is 1.4.5, but the application doesn't support "-d install" parameter to install itself as Windows service.

    So right now the 1.4.4 is still the option to go under Windows. Get a package from memcached 1.4.4 for Windows 32-bit from

    Unzipped to a folder, then run the following command to install as win services
    memcached.exe -d install

    Start the server from the Microsoft Management Console or by running one of the following commands: 
    memcached.exe -d start

    2. Check Memcached installation

    You can telnet to the default port 11211 to check the status:
    telnel localhost 11211

    Then use the command stats to check status

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Newtonsoft.Json;
    using Enyim.Caching;
    using Enyim.Caching.Memcached;
    namespace MemCching
        public partial class _Default : System.Web.UI.Page
            protected void Page_Load(object sender, EventArgs e)
            protected void Button1_Click(object sender, EventArgs e)
                List<User> lst = new List<MemCching.User>();
                List<User> lst2 = new List<MemCching.User>();
                User ob = new MemCching.User();
                ob.UserID = "1";
                ob.UserName = "aditya";
                JsonSerializerSettings s = new JsonSerializerSettings();
                s.NullValueHandling = NullValueHandling.Ignore;
                s.MissingMemberHandling = MissingMemberHandling.Ignore;
                s.DefaultValueHandling = DefaultValueHandling.Ignore;
                bool b = false;
                bool c = false;
                string varCache = "SpibayProduct";
                MemcachedClient Cache = new MemcachedClient();
                string stringList = JsonConvert.SerializeObject(lst, Formatting.None, s);
                // a = Cache.Remove(varCache)
                if (Cache.Get(varCache) == null == true)
                    b = Cache.Store(StoreMode.Add, varCache, stringList, DateTime.Now.AddDays(30));
                    c = Cache.Store(StoreMode.Replace, varCache, stringList, DateTime.Now.AddDays(30));
      if (Cache.Get(varCache) == null == false)
                    var str = Cache.Get(varCache);
                    lst2 = JsonConvert.DeserializeObject<List<User>>(str.ToString());
        public class User
            public string UserID {get;set;}
            public string UserName {get;set;}

        <sectionGroup name="">
          <section name="memcached" type="Enyim.Caching.Configuration.MemcachedClientSection,Enyim.Caching"/>
        <memcached protocol="Binary">
            <add address="" port="11211"/>
          <keyTransformer type="Enyim.Caching.Memcached.TigerHashKeyTransformer, Enyim.Caching" />

      Modified On Apr-10-2018 06:32:33 AM
  1. Post:281

    Re: how to use memcache

    This is the best way to use memcache!!

      Modified On Dec-15-2015 09:50:25 PM