   `(let [conn# (connection)
          ~'index-name (:index-name conn#)
          ~'ids-inst (:ids-inst conn#)
+         ~'cache-inst (:cache-inst conn#)
          ~'instance-context (:instance-context conn#)
          ~'stats-context (:stats-context conn#)
          ~'population-use (:population-use conn#)

    (elasticsearch-connection \"tmp\" :create-instances-fn load-fn)))
```"
  [index-name &
   {:keys [create-instances-fn population-use set-type url mapping-type-def]
    :or {create-instances-fn identity
         population-use 1.0
         set-type :train

  ([id]
   (use-connection
     (with-context [instance-context]
       (if cache-inst
         (letfn [(sfn [data]
                   (if-not (contains? data id)
                     (assoc data id (es/document-by-id id))
                     data))]
           (swap! cache-inst sfn)
           (get @cache-inst id))
         (es/document-by-id id))))))

(defn clear
  "Clear the in memory instance data.  If key `:wipe-persistent?` is `true` all
