/// <summary> /// This method queries items in the cache on which index was defined using NCache Manager. /// </summary> private static void QueryItemsUsingDefinedIndex() { // Query can only be applied to C# Primitive data types: // and for those non primitive data types whose indexes are defined in NCache manager string query = "SELECT $Value$ FROM Alachisoft.NCache.Sample.Data.Product WHERE UnitPrice > ?"; QueryCommand queryCommand = new QueryCommand(query); queryCommand.Parameters.Add("UnitPrice", Convert.ToDecimal(100)); ICacheReader reader = _cache.SearchService.ExecuteReader(queryCommand); int counter = 0; if (reader.FieldCount > 0) { while (reader.Read()) { var product = reader.GetValue <Product>(1); PrintProductDetails(product); counter++; } } Console.WriteLine("{0} cache items fetched from cache using query on unit price.\n", counter); }
protected NCacheOqlEnumerator(ICacheReader cacheReader) { Logger.Log( "Running " + GetType().Name + " enumerator.", Microsoft.Extensions.Logging.LogLevel.Debug ); reader = cacheReader; }
public void Initialize() { header = GetHeader(); cacheWriter = SharedCacheFactory.Instance.CacheWriter; cacheWriter.RegisterHeader(header); cacheReader = SharedCacheFactory.Instance.CacheReader; cacheReader.RegisterHeader(header); }
internal NCacheOqlEnumerable(EnumerableType type, ICacheReader cacheReader) { switch (type) { case EnumerableType.Normal: enumeratorWrapper = new NCacheOqlEnumeratorNormal <T>(cacheReader); break; case EnumerableType.Deferred: enumeratorWrapper = new NCacheOqlEnumeratorDeferred <T>(cacheReader); break; } }
/// <summary> /// This method fetches items from the cache using named tags. /// </summary> private static void GetItems() { string query = "SELECT Alachisoft.NCache.Sample.Data.Order WHERE this.Category = ? AND this.ProductName = ?"; Hashtable values = new Hashtable(); values["Category"] = "Beverages"; values["ProductName"] = "Coke"; ICacheReader result = _cache.ExecuteReader(query, values); if (!result.IsClosed) { while (result.Read()) { Console.WriteLine(result[0].ToString()); } } }
/// <summary> /// This method queries cached data /// </summary> /// <param name="customer"> Instance of registered continuous query to query cached items</param> private static void QueryDataInCache(ContinuousQuery continuousQuery) { // Getting key-value pair via query // Much faster way ... avoids round trip to cache ICacheReader cacheReader = _cache.ExecuteReaderCQ(continuousQuery, true); if (!cacheReader.IsClosed) { // Print output on console Console.WriteLine("\nFollowing items are fetched with Continuous Query."); while (cacheReader.Read()) { var asd = cacheReader[0]; Customer customerFound = (Customer)cacheReader[1]; PrintCustomerDetails(customerFound); } } }
/// <summary> /// This method fetches items from the cache using named tags. /// </summary> private static void GetItems() { string query = "SELECT Alachisoft.NCache.Sample.Data.Order WHERE this.Category = ? AND this.ProductName = ?"; QueryCommand itemQuery = new QueryCommand(query); itemQuery.Parameters.Add("Category", "Beverages"); itemQuery.Parameters.Add("ProductName", "Coke"); ICacheReader result = _cache.SearchService.ExecuteReader(itemQuery, true); if (!result.IsClosed) { while (result.Read()) { Console.WriteLine(result.GetString(0)); } } }
/// <summary> /// This method queries cached data /// </summary> /// <param name="customer"> Instance of registered continuous query to query cached items</param> private static void QueryDataInCache(QueryCommand queryCommand) { // Getting keyvalue pair via query // Much faster way ... avoids round trip to cache //ICacheReader cacheReader = _cache.ExecuteReaderCQ(continuousQuery, true); ICacheReader cacheReader = _cache.SearchService.ExecuteReader(queryCommand, true); if (!cacheReader.IsClosed) { // Print output on console Console.WriteLine("\nFollowing items are fetched with Continuous Query."); while (cacheReader.Read()) { var asd = cacheReader.GetValue <object>(0); Customer customerFound = cacheReader.GetValue <Customer>(1); PrintCustomerDetails(customerFound); } } }
/// <summary> /// This method queries Items from NCache using named tags. /// </summary> private static void QueryItemsUsingNamedTags() { // Defining Searching criteria Hashtable criteria = new Hashtable(); criteria["Employee"] = "DavidBrown"; string query = "SELECT System.String WHERE this.Employee = ?"; ICacheReader result = _cache.ExecuteReader(query, criteria); if (!result.IsClosed) { while (result.Read()) { Console.WriteLine(result[0].ToString()); } } Console.WriteLine(); }
/// <summary> /// This method queries items from the cache using both named tags and pre-defined index. /// </summary> private static void QueryItemsUsingNamedTagsAndIndex() { string query = "SELECT Alachisoft.NCache.Sample.Data.Product Where this.ProductName = ?"; var criteria = new Hashtable(); criteria["ProductName"] = "HTCPhone"; ICacheReader result = _cache.ExecuteReader(query, criteria); if (!result.IsClosed) { while (result.Read()) { Product productFound = (Product)result[1]; PrintProductDetails(productFound); } } Console.WriteLine(); }
/// <summary> /// This method queries cached keys /// </summary> /// <param name="customer"> Instance of registered continuous query to query cached items</param> private static void QueryKeysInCache(ContinuousQuery continuousQuery) { // Getting keys via query ICacheReader cacheReader = _cache.ExecuteReaderCQ(continuousQuery, false); if (!cacheReader.IsClosed) { // Print output on console Console.WriteLine("\nFollowing keys are fetched with Continuous Query."); while (cacheReader.Read()) { string key = (string)cacheReader[0]; Console.WriteLine("Key: " + key); // A second call to cache to fetch the customer //Customer cachedCustomer = (Customer)_cache.Get(key); } } }
/// <summary> /// This method queries cached keys /// </summary> /// <param name="customer"> Instance of Query Command to query cached items</param> private static void QueryKeysInCache(QueryCommand queryCommand) { // Getting keys via query //ICacheReader cacheReader = _cache.ExecuteReaderCQ(continuousQuery, false); ICacheReader cacheReader = _cache.SearchService.ExecuteReader(queryCommand, false); if (!cacheReader.IsClosed) { // Print output on console Console.WriteLine("\nFollowing keys are fetched with Continuous Query."); while (cacheReader.Read()) { string key = cacheReader.GetValue <string>(0); Console.WriteLine("Key: " + key); // A second call to cache to fetch the customer //Customer cachedCustomer = (Customer)_cache.Get(key); } } }
/// <summary> /// This method queries Items from NCache using named tags. /// </summary> private static void QueryItemsUsingNamedTags() { string query = "SELECT $Value$ FROM Alachisoft.NCache.Sample.Data.Product WHERE Supplier = ?"; QueryCommand queryCommand = new QueryCommand(query); // Defining Searching criteria queryCommand.Parameters.Add("Supplier", "Tokyo Traders"); ICacheReader reader = _cache.SearchService.ExecuteReader(queryCommand); int counter = 0; if (reader.FieldCount > 0) { while (reader.Read()) { var product = reader.GetValue <Product>(1); PrintProductDetails(product); counter++; } } Console.WriteLine("{0} cache items fetched from cache using query on named tags.\n", counter); }
/// <summary> /// This method queries items in the cache on which index was defined using NCache Manager. /// </summary> private static void QueryItemsUsingPreDefinedIndex() { // Query can only be applied to C# Primitive data types: // and for those non primitive data types whose indexes are defined in NCache manager string query = "SELECT Alachisoft.NCache.Sample.Data.Product Where this.Id = ?"; var criteria = new Hashtable(); criteria["Id"] = 1; ICacheReader result = _cache.ExecuteReader(query, criteria); if (!result.IsClosed) { while (result.Read()) { Product productFound = (Product)result[1]; PrintProductDetails(productFound); } } Console.WriteLine(); }
/// <summary> /// This method queries items from the cache using projection attributes. /// </summary> private static void QueryItemsUsingProjection() { string query = "SELECT Name, Supplier FROM Alachisoft.NCache.Sample.Data.Product WHERE UnitPrice > ?"; QueryCommand queryCommand = new QueryCommand(query); queryCommand.Parameters.Add("UnitPrice", Convert.ToDecimal(100)); ICacheReader reader = _cache.SearchService.ExecuteReader(queryCommand); int counter = 0; if (reader.FieldCount > 0) { while (reader.Read()) { Console.WriteLine("Name: " + reader.GetValue <string>("Name")); Console.WriteLine("Supplier: " + reader.GetValue <string>("Supplier")); Console.WriteLine(); counter++; } } Console.WriteLine("{0} cache items fetched from cache using projection query on unit price.\n", counter); }
internal NCacheOqlEnumeratorNormal(ICacheReader cacheReader) : base(cacheReader) { }
public TypeResolver(ICacheReader cache) { _cache = cache; }
public TypeResolver(ICacheReader cache) { _cache = cache; }
public SequenceKeyedCaching(CacheHeaderInfo header, ICacheWriter cacheWriter, ICacheReader cacheReader) { this.header = header; this.cacheWriter = cacheWriter; this.cacheReader = cacheReader; }
internal NCacheOqlEnumeratorDeferred(ICacheReader cacheReader) : base(cacheReader) { key = 0; genericTypes = typeof(TSource2).GetGenericArguments(); }