// Collection of code snippets by Arne Vajhøj // (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) using System; using Enyim.Caching; using Enyim.Caching.Configuration; using Enyim.Caching.Memcached; namespace Cache.Memcached.Functional { public class Program { private static void Test(MemcachedClient cache) { // basic put, get and remove cache.Store(StoreMode.Set, "v", 123); Console.WriteLine(cache.Get("v")); cache.Remove("v"); Console.WriteLine(cache.Get("v")); cache.Store(StoreMode.Set, "v", 123); Console.WriteLine(cache.Get("v")); // persistence int? counter = cache.Get("counter"); if(counter == null) { counter = 0; } counter++; Console.WriteLine(counter); cache.Store(StoreMode.Set, "counter", counter); // list all not supported // listener not supported } public static void Main(string[] args) { MemcachedClientConfiguration cfg = new MemcachedClientConfiguration(); cfg.Protocol = MemcachedProtocol.Binary; cfg.AddServer("localhost:11211"); using(MemcachedClient cache = new MemcachedClient(cfg)) { Test(cache); } } } }