GetLatestFromTableStorageAsync() 공개 메소드

This is a full table scan. Yuck.
public GetLatestFromTableStorageAsync ( ) : Task>
리턴 Task>
예제 #1
0
        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);
        }