// Collection of code snippets by Arne Vajhøj // (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) using System; using System.Collections.Generic; using Apache.Ignite.Core; using Apache.Ignite.Core.Client; using Apache.Ignite.Core.Client.Cache; namespace Cache.IgniteThin.Functional { public class Program { private static void Test(ICacheClient cache) { // basic put, get and remove cache.Put("v", 123); Console.WriteLine(cache.Get("v")); cache.Remove("v"); Console.WriteLine(cache.ContainsKey("v") ? cache.Get("v") : null); // non-existing key throws exception - does not return null cache.Put("v", 123); Console.WriteLine(cache.Get("v")); // persistence int? counter = cache.ContainsKey("counter") ? cache.Get("counter") : 0; // non-existing key throws exception - does not return null counter++; Console.WriteLine(counter); cache.Put("counter", counter); // list all not supported using thin // listener not supported using thin } public static void Main(string[] args) { IgniteClientConfiguration cfg = new IgniteClientConfiguration { Endpoints = new List { "localhost:10800" } }; using (IIgniteClient cli = Ignition.StartClient(cfg)) { ICacheClient cache = cli.GetOrCreateCache("functional_cache"); Test(cache); } } } }