How to use Memcache MVC in three-tier project

Memcache Overview:

memcache is a set of open source distributed caching system. And client by the service composition in daemon (monitor) run on one or more servers, ready to receive the client's connection and operation. memcache main target data cached in memory, by maintaining a unified memory in a huge hash table. Simply put, it is to call the data into memory, and then read from memory, thus greatly improving the read speed. memcache objects stored in memory based on a store key / value pairs hashmap. memcache is written in C, but the client can be written in any language, and by agreement with the memcached daemon communication.

 

Memcache features:

  • The amount of the data item can be stored in Memcached is not limited, as long as enough memory.
  • Memcached single process using a maximum 32-bit system memory to 2G, there are no restrictions if the 64-bit system, this is due to the 32-bit system limitation up to a single process using 2G memory, more memory to be used, can be divided into a plurality of open ports Memcached multiple processes.
  • A maximum of 30 days of data expiration time, will set up a permanent expire at this time, constant REALTIME_MAXDELTA
  • The maximum single data item is 1MB, not more than 1MB data storage, control constants POWER_BLOCK 1048576

 

Dll file 1. introduction 4

 

 

 

 

Private  static  Readonly MemcachedClient MC = null ; 

        static MemcacheHelper () 
        { 
            // is preferably in a configuration file 
            String [] = {ServerList " 127.0.0.1:11211 " , " 10.0.0.132:11211 " }; 

            // initialize pool 
            SockIOPool = the pool SockIOPool.GetInstance (); 
            pool.SetServers (ServerList); 

            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();

            // 获得客户端实例
            mc = new MemcachedClient();
            mc.EnableCompression = false;
        }

 

Guess you like

Origin www.cnblogs.com/liutaovip/p/12636929.html