/// <summary> /// This method handles data modification callbacks /// </summary> /// <param name="key"> Modifed string key </param> /// <param name="key"> Metada about updated item in cache</param> private static void QueryDataModified(string @string, CQEventArg cQEventArg) { // Print output on console Console.WriteLine("\nContinuous Query data modification event is received from cache."); switch (cQEventArg.EventType) { case EventType.ItemAdded: Console.WriteLine(@string + " is added to cache."); break; case EventType.ItemRemoved: Console.WriteLine(@string + " is removed from cache."); break; case EventType.ItemUpdated: Console.WriteLine(@string + " is updated in cache."); if (cQEventArg.Item != null) { PrintCustomerDetails(cQEventArg.Item.GetValue <Customer>()); } break; default: break; } }
private void QueryItemCallBackForInvaluableCustomers(string key, CQEventArg arg) { var cacheItem = _cache.GetCacheItem(key); cacheItem.Expiration = new Expiration(ExpirationType.Sliding, new TimeSpan(0, 0, 5)); _cache.Insert(key, cacheItem); }
private void QueryItemCallBackForGoldCustomers(string key, CQEventArg arg) { var cacheItem = _cache.GetCacheItem(key); cacheItem.Expiration = new Expiration(ExpirationType.None); Tag[] tags = new Tag[1]; tags[0] = new Tag("GoldCustomers"); cacheItem.Tags = tags; _cache.Insert(key, cacheItem); ICollection <string> retrievedKeys = _cache.SearchService.GetKeysByTag(tags[0]); }
private void QueryItemCallBack(string key, CQEventArg arg) { var cacheItem = _cache.GetCacheItem(key); cacheItem.Expiration = new Expiration(ExpirationType.None); Tag[] tags = new Tag[1]; tags[0] = new Tag("ValuableCustomers"); cacheItem.Tags = tags; _cache.Insert(key, cacheItem); ICollection <string> retrievedKeys = _cache.SearchService.GetKeysByTag(tags[0]); Console.Clear(); Console.WriteLine("{0} Valuable Customers Count:{1}", arg.EventType.ToString(), retrievedKeys.Count); }