          (satisfies? dc/ISearch db)
          (satisfies? dc/IIndexAccess db)]}
   (when-let [e (entid db eid)]
-    (Entity. db e false {})))
+    (->Entity db e (volatile! false) (volatile! {}))))
 
 (defn- entity-attr [db a datoms]
   (if (dc/multival? db a)

      (entity db (.-v (first datoms)))
      (.-v (first datoms)))))

(defn- datoms->cache [db datoms]
  (reduce (fn [acc part]
    (let [a (.-a (first part))]
      (assoc acc a (entity-attr db a part))))
    {} (partition-by :a datoms)))

(defn touch-components [db a->v]
  (reduce-kv (fn [acc a v]

(ns datascript.impl.entity
  (:refer-clojure :exclude [keys get])
  (:require [#?(:cljs cljs.core :clj clojure.core) :as c]
            [datascript.core :as dc]))

(declare entity ->Entity equiv-entity lookup-entity touch)

(defn- entid [db eid]
  (when (or (number? eid)
