 class _globalSearchSingleton extends Spine.Module
 
   constructor: ->
-    @searchResultCache = {}
+    @searchResultCache = undefined
+    @searchResultCacheByKey = {}
     @apiPath = App.Config.get('api_path')
 
   execute: (params) ->

      data:
        query: query
        limit: limit
      processData: true,
      success: (data, status, xhr) =>
        App.Collection.loadAssets(data.assets)
        result = {}

          else
            App.Log.error('_globalSearchSingleton', "No such model App.#{item.type}")

        @renderTry(render, result, cacheKey)
    )

  renderTry: (render, result, cacheKey) =>

    # if result hasn't changed, do not rerender
    diff = false
    if @searchResultCache
      diff = difference(@searchResultCache, result)
    return if diff isnt false && _.isEmpty(diff)

    # cache search result
    @searchResultCache = result
    @searchResultCacheByKey[cacheKey] =
      result: result
      time: new Date

    render(result)
