Gets recent Flickr photos (up to limit) for the specified username. The return value of this method is cached to improve performance and to avoid abusing the Flickr API.
# File plugin/thoth_flickr.rb, line 59 def recent_photos(username, limit = 4) @cache ||= {} key = "recent_photos_#{username}_#{limit}" if cached = @cache[key] return cached[:value] if cached[:expires] > Time.now end @flickr ||= Net::Flickr.new(Config.flickr.api_key) begin Timeout.timeout(Config.flickr.request_timeout.to_i, StandardError) do @cache[key] = { :expires => Time.now + Config.flickr.cache_ttl.to_i, :value => @flickr.people.find_by_username(username). photos(:per_page => limit) } end rescue => e return [] else @cache[key][:value] end end
Generated with the Darkfish Rdoc Generator 2.