public GetLatestFromTableStorageAsync ( ) : Task
|
||
Résultat | Task
|
public async Task<IHttpActionResult> Get() { var cache = RedisCache.Connection.GetDatabase(); var repo = new RedisRepository(cache); var items = await repo.GetAllPhotosAsync(); List<IPhotoModel> typedItems = new List<IPhotoModel>(items); if(typedItems.Count == 0) { //Pull from storage. This is a cross-partition query, // and will be slower than using Redis. var storageConnectionString = SettingsHelper.LocalStorageConnectionString; var storageRepo = new StorageRepository(storageConnectionString); typedItems = await storageRepo.GetLatestFromTableStorageAsync(); if(typedItems.Count > 0) { foreach (var item in typedItems) { //Add to cache as cache-aside pattern await repo.AddPhotoToAllUsersCacheAsync(item); } items = typedItems; } } return Ok(items); }