internal static List <TItem> Set <TItem>(this NCacheWrapper cache, object key, Dictionary <string, TItem> value, CachingOptions options, Alachisoft.NCache.Runtime.Dependencies.CacheDependency dbDependency, StoreAs storingAs) { Logger.Log( "About to set values with options " + options.ToLog() + ", DbDependency '" + dbDependency + "' and StoringAs '" + storingAs + "'.", Microsoft.Extensions.Logging.LogLevel.Trace ); // Add entities if stroing as seperateEntities if (storingAs == StoreAs.SeperateEntities) { Logger.Log("Values are about to be set as separate entities.", Microsoft.Extensions.Logging.LogLevel.Trace); cache.Set(value.Keys.ToArray(), value.Values.ToArray(), options, dbDependency, storingAs); } // from here onwards is the enumerator logic and now it is being done in "else" after we have moved to tags based result set regeneration else { Logger.Log("Values are about to be set as collection.", Microsoft.Extensions.Logging.LogLevel.Trace); // Add query enumerator CacheEntry entry = cache.CreateEntry(key); // Setting options if (options != null) { entry.SetOptions(options); } // Setting Value if (storingAs == StoreAs.Collection) { entry.Value = value.Values.ToList(); } // Mind that this is not the user specified option but the end storing methodology entry.StoredAs = storingAs; // Set dependencies in the entry var aggregateDependency = new AggregateCacheDependency(); if (dbDependency != null) { aggregateDependency.Add(dbDependency); } entry.Dependencies = aggregateDependency; cache.Set(key, entry, options, dbDependency, storingAs); } return(value.Values.ToList()); }
internal static TItem SetAsCacheEntry <TItem>(this NCacheWrapper cache, object key, TItem value, CachingOptions options, CacheDependency dbDependency) { Logger.Log( "Setting CacheEntry '" + value + "' against key '" + key + "' with DbDependency '" + dbDependency + "'", Microsoft.Extensions.Logging.LogLevel.Trace ); CacheEntry entry = cache.CreateEntry(key); if (options != null) { entry.SetOptions(options); } if (dbDependency != null) { entry.Dependencies = dbDependency; } entry.Value = value; cache.Set(key, entry, options, dbDependency, options.StoreAs); return(value); }