/// <summary> /// Creates a data loader for the specified table. /// </summary> /// <param name="table"> The metadata of the table. </param> /// <returns> /// The data loader for the table. /// </returns> public ITableDataLoader CreateTableDataLoader(TableDescription table) { CachingTableDataLoaderKey key = new CachingTableDataLoaderKey( new DataLoaderConfigurationKey(this.wrappedDataLoader), table.Name); // If the table data cache does not exists, then the data loader configuration // should be locked if (latch != null && !this.dataStore.Contains(key)) { // Wait for the lock, this could take some time latch.Acquire(); // Check if the data was created since the waiting if (this.dataStore.Contains(key)) { latch.Release(); } } // It does not matter if the table data cache was created during the waiting, // maybe there is still tables thats data is not fetched return(this.dataStore.GetCachedData(key, () => CreateCachedData(table))); }
public CachingTableDataLoader GetCachedData( CachingTableDataLoaderKey key, Func<CachingTableDataLoader> factoryMethod) { CachingTableDataLoader result = null; if (!this.simpleCache.TryGetValue(key, out result)) { result = factoryMethod.Invoke(); this.simpleCache.Add(key, result); } else { this.CachedItemReturnCount++; } return result; }
public CachingTableDataLoader GetCachedData( CachingTableDataLoaderKey key, Func <CachingTableDataLoader> factoryMethod) { CachingTableDataLoader result = null; if (!this.simpleCache.TryGetValue(key, out result)) { result = factoryMethod.Invoke(); this.simpleCache.Add(key, result); } else { this.CachedItemReturnCount++; } return(result); }
public bool Contains(CachingTableDataLoaderKey key) { return this.simpleCache.ContainsKey(key); }
/// <summary> /// Determines whether the desired table data is added to store. /// </summary> /// <param name="key"> /// The key that identifies the table data. /// </param> /// <returns> /// <c>true</c> if the store contains the data, otherwise <c>false</c>. /// </returns> public bool Contains(CachingTableDataLoaderKey key) { return(CachingTableDataLoaderStore.Contains(key)); }
/// <summary> /// Returns the stored table data. /// </summary> /// <param name="key"> /// The key that identifies the table data. /// </param> /// <param name="factoryMethod"> /// The factory method that initilizes the table data if has not been added to the /// store yet. /// </param> /// <returns> /// The table data. /// </returns> public CachingTableDataLoader GetCachedData( CachingTableDataLoaderKey key, Func <CachingTableDataLoader> factoryMethod) { return(CachingTableDataLoaderStore.GetCachedData(key, factoryMethod)); }
public bool Contains(CachingTableDataLoaderKey key) { return(this.simpleCache.ContainsKey(key)); }
/// <summary> /// Creates a data loader for the specified table. /// </summary> /// <param name="table"> The metadata of the table. </param> /// <returns> /// The data loader for the table. /// </returns> public ITableDataLoader CreateTableDataLoader(TableDescription table) { CachingTableDataLoaderKey key = new CachingTableDataLoaderKey( new DataLoaderConfigurationKey(this.wrappedDataLoader), table.Name); // If the table data cache does not exists, then the data loader configuration // should be locked if (latch != null && !this.dataStore.Contains(key)) { // Wait for the lock, this could take some time latch.Acquire(); // Check if the data was created since the waiting if (this.dataStore.Contains(key)) { latch.Release(); } } // It does not matter if the table data cache was created during the waiting, // maybe there is still tables thats data is not fetched return this.dataStore.GetCachedData(key, () => CreateCachedData(table)); }
/// <summary> /// Returns the stored table data. /// </summary> /// <param name="key"> /// The key that identifies the table data. /// </param> /// <param name="factoryMethod"> /// The factory method that initilizes the table data if has not been added to the /// store yet. /// </param> /// <returns> /// The table data. /// </returns> public CachingTableDataLoader GetCachedData( CachingTableDataLoaderKey key, Func<CachingTableDataLoader> factoryMethod) { return CachingTableDataLoaderStore.GetCachedData(key, factoryMethod); }
/// <summary> /// Determines whether the desired table data is added to store. /// </summary> /// <param name="key"> /// The key that identifies the table data. /// </param> /// <returns> /// <c>true</c> if the store contains the data, otherwise <c>false</c>. /// </returns> public bool Contains(CachingTableDataLoaderKey key) { return CachingTableDataLoaderStore.Contains(key); }