Memched is still relatively simple, here the C # related operations organized a bit, mark~
1 /// <summary>2 ///The cache action class. 3 /// </summary>4 /// <remarks>5 ///Introduction:6 ///memcached is an open-source, high-performance distributed cache system that is stored in the form of Key-value, simple and powerful, with fast development speed. 7 ///Installation Tutorials:http://www.runoob.com/memcached/memcached-install.html8 ///use similar:/usr/bin/memcached-p 11211-u root-d Boot9 ///Store Command:Ten ///memcached Really simple, set, add, replace, append, prepend, cas command parameters are basically the same, here is the one by one-prefix, take set as an example, One ///Set Key flags exptime bytes [noreply] A ///value - ///Key : Keys in Key-value; - ///Flags: Additional information for storing key-value pairs; the ///Exptime: The expiration time is in seconds, and 0 means forever - ///Bytes: The number of bytes stored in the cache - ///noreply (optional): tells the server not to return data - ///Value : Stored values (always on the second row) + ///Other Commands: - ///get key: Find command, multi-value lookup please use get key1 key2 Key3 + ///Delete key: Remove command A ///Stats: Return statistics at ///flush all: Used to clean all the keys in the cache - /// </remarks> - Public classMemcachedcore - { - Publicmemcachedclient _mclient; - in /// <summary> - ///initialized. to /// </summary> + /// <param name= "ConnStr" >Link String Example: 127.0.0.1:11211</param> - /// <param name= "poolname" ></param> the PublicMemcachedcore (stringConnStr,stringPoolname ="") * { $_mclient =Newmemcachedclient ();Panax Notoginseng_mclient.poolname =poolname; -_mclient.enablecompression =false; the + //Initialize ASockiopool Pool;//Memcache pool can be associated with more than one server, although memcached is distributed, but itself is not supported, you need to write a distributed policy on the client, through the weight to implement the if(string. IsNullOrEmpty (poolname)) +Pool =sockiopool.getinstance (); - Else $Pool =sockiopool.getinstance (_mclient.poolname); $Pool. Setservers (New string[] {connstr}); -Pool. Nagle =false; - pool. Initialize (); the } - Wuyi Public voidSet<t> (stringkey, T obj) the { - _mclient.set (key, obj); Wu } - About Public voidSet<t> (stringkey, T obj, DateTime expiretime) $ { - _mclient.set (key, obj, expiretime); - } - A Public voidAdd<t> (stringkey, T obj) + { the _mclient.add (key, obj); - } $ the Public voidAdd<t> (stringkey, T obj, DateTime expiretime) the { the _mclient.add (key, obj, expiretime); the } - in Public voidUpdate<t> (stringkey, T obj) the { the _mclient.replace (key, obj); About } the the Public voidUpdate<t> (stringkey, T obj, DateTime expiretime) the { + _mclient.replace (key, obj, expiretime); - } the Bayi Public voidDelete (stringkey) the { the _mclient.delete (key); - } - the PublicT get<t> (stringkey) the { the return(T) _mclient.get (key); the } - the PublicList<t> getlist<t> (string[] keys) the { the return_mclient.getmultiplearray (keys). Select (p =(T) p). ToList ();94 } the}
memched--c# operation