# File lib/plugins/appendtitle.rb, line 13
  def self.fetch_title(uri)
    return unless uri
    key = %w{ plugins appendtitle title}.push(Digest::SHA1.hexdigest(uri)).join('-')
    if v = memory_cache.get(key)
      logger.debug "appendtitle: cache hit for #{uri}"
      return v
    end

    memory_cache.set(key, '', config.plugins.appendtitle.cache_expire) # to avoid duplicate fetch
    begin
      logger.debug "appendtitle: fetching title for #{uri}"
      source = Nokogiri(open(uri).read)
      if source and source.at('title')
        title = source.at('title').text
        memory_cache.set(key, title, config.plugins.appendtitle.cache_expire)
        return title
      end
      nil
     rescue Timeout::Error, StandardError
      nil
    end
  end