public GetPhotosFromTableAsync ( string tableName, string partitionKey ) : Task |
||
tableName | string | |
partitionKey | string | |
return | Task |
public async Task<IHttpActionResult> Get() { var cache = RedisCache.Connection.GetDatabase(); var repo = new RedisRepository(cache); string owner = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value; var items = await repo.GetPhotosForUserAsync(owner); //Do this so we can get the count List<IPhotoModel> typedItems = new List<IPhotoModel>(items); if(typedItems.Count == 0) { //Nothing in cache... head off to storage. var storageRepo = new StorageRepository(SettingsHelper.LocalStorageConnectionString); var photos = await storageRepo.GetPhotosFromTableAsync( DAL.Azure.StorageConfig.TableName, owner); foreach (var photo in photos) { //TODO: Find a MUCH better algorithm than // iterating every item and calling // Redis 3 times in a row for each // item. This is PAINFUL. await repo.AddPhotoToCachesAsync(photo); } items = photos; } return Ok(items); }