public GetPhotoFromTableAsync ( string tableName, string partitionKey, string rowKey ) : Task |
||
tableName | string | |
partitionKey | string | |
rowKey | string | |
return | Task |
public async Task<IHttpActionResult> GetPhotoModel(string id) { var cache = RedisCache.Connection.GetDatabase(); var repo = new RedisRepository(cache); //Get a single item from the cache based on its ID var photo = await repo.GetPhotoByIDAsync(id); if (null == photo) { //Not in the cache. Retrieve from storage. string connectionString = SettingsHelper.LocalStorageConnectionString; string owner = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value; var storageRepo = new StorageRepository(connectionString); photo = await storageRepo.GetPhotoFromTableAsync( DAL.Azure.StorageConfig.PhotosBlobContainerName, owner, id); if (null == photo) { //Not found in cache or storage. } else { //Update the cache using the cache aside pattern. await repo.AddPhotoToUserCacheAsync(photo); } } if (null != photo) { return Ok(photo); } else { return NotFound(); } }