---
title: "how to use memcache"  
description: "how to use memcache"  
author: "Anonymous User"  
published: 2015-10-31  
updated: 2015-12-13  
canonical: https://www.mindstick.com/forum/33554/how-to-use-memcache  
category: ".net"  
tags: ["mvc"]  
reading_time: 3 minutes  

---

# how to use memcache

how to use memcache

## Replies

### Reply by Anonymous User

This is the best way to use memcache!!

### Reply by Anonymous User

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 http://downloads.northscale.com/memcached-win32-1.4.4-14.zip.\
\
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\
stats\
flush_all**\****\**

```
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";            lst.Add(ob);            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));            }            else            {                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;}    }}<configSections>    <sectionGroup name="enyim.com">      <section name="memcached" type="Enyim.Caching.Configuration.MemcachedClientSection,Enyim.Caching"/>    </sectionGroup>  </configSections> <enyim.com>    <memcached protocol="Binary">      <servers>        <add address="127.0.0.1" port="11211"/>      </servers>      <keyTransformer type="Enyim.Caching.Memcached.TigerHashKeyTransformer, Enyim.Caching" />    </memcached>  </enyim.com>
```


---

Original Source: https://www.mindstick.com/forum/33554/how-to-use-memcache

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
