Flickr.NET performance problems when getting photos

I'm currently working on an ASP.NET site which needs to show photos from Flickr as multiple slideshows/galleries on the frontpage. I am using the Flickr.NET library to interact with Flickr.My Flickr structure is as follows:
  • 2012 (Collection)
    • Artists (Collection)Artist1 (Set)Photo1
    • Photo2
    • Photo3
And so on, so forth. There can, of course, be more childcollections and more sets under these collections.On the page I'm only interested in showing the sets (the collection is basically just for structuring the galleries so it's easier for the photographers to work with in Lightroom) I've written a recursive method to loop through the collections getting their sets. Code:\[code\]private static List<CollectionSet> _photoSets;public void GetFlickrPhotosetsRecursive(List<Collection> collections) { // Loop through the collections foreach (var collection in collections) { // Base case: this collection has no childcollections and have got at least one set if (collection.Collections.Count == 0 && collection.Sets.Count > 0) { _photoSets.AddRange(collection.Sets); } else { // Check if this collection has got any sets if (collection.Sets.Count > 0) _photoSets.AddRange(collection.Sets); // Call method again with child collections GetFlickrPhotosetsRecursive(collection.Collections.ToList()); } } }\[/code\]This runs smooth without any performance problems at all. Reason for this is, that Collections, child collections and sets are loaded in one call to the Flickr API. Now, when I need to get the photos of each of the sets, this causes some serious performanceproblems. It takes almost 10 seconds to load the page since each photo lookup is a call to the API. Code:\[code\]GetFlickrPhotosetsRecursive(collections.ToList());return _photoSets.Select(set => new FlickrGallery() { PhotoCollection = GetPhotosFromPhotoSet(set.SetId), SetId = set.SetId, Title = set.Title }).ToList();public PhotosetPhotoCollection GetPhotosFromPhotoSet(string setId){ return _flickr.PhotosetsGetPhotos(setId);}\[/code\]The FlickrGallery object is an object of mine to store the information I need on the frontend.So, does anyone know of a better way to do this to prevent huge load times? This is still proof of concept and there's only 30 sets with 1 - 5 photos each. Can't imagine the load time when it goes live with 80+ sets with 40+ photos in each set :-)Any help/hint on this is greatly appreciated!Thanks a lot in advance.All the best,Bo
 
Back
Top