           cache-batched (with-cache stream-cache batched key-fn value-fn)]
       (cache-batched version action dataset collection id validity geometry attributes)))
   (current-validity [_ dataset collection id]
-    (let [key-fn (fn [& params] (->> params (take 3)))
+    (let [key-fn (fn [dataset collection id] [dataset collection id])
           load-cache (fn [dataset collection id]
                        (when (stream-load-cache? dataset collection) (jdbc-load-cache db dataset collection)))
           cached (use-cache stream-cache key-fn load-cache)]
       (first (cached dataset collection id))))
   (last-action [_ dataset collection id]
-    (let [key-fn (fn [& params] (->> params (take 3)))
+    (let [key-fn (fn [dataset collectioni id] [dataset collection id])
           load-cache (fn [dataset collection id]
                        (when (stream-load-cache? dataset collection) (jdbc-load-cache db dataset collection)))
           cached (use-cache stream-cache key-fn load-cache)]

                      dataset parent-collection parent-id child-collection] :as-arrays? true)]
      results)))

(defn- jdbc-insert
  ([db version action dataset collection id validity geometry attributes]
   (jdbc-insert db (list [version action dataset collection id validity geometry attributes])))

  (current-validity [this dataset collection id])
  (last-action [this dataset collection id])
  (childs [this dataset parent-collection parent-id child-collection])
  (parent [this dataset collection id] "Returns [collection id] tuple or nil")
  (close [_])
  )

(defn path [persistence dataset collection id]
  "Returns sequence of [collection id] tuples. Parents first. Root only means empty sequence"
  (when (and dataset collection id)
    (if-let [[parent-collection parent-id] (parent persistence dataset collection id)]
      (loop [path (list)
             pc  parent-collection
             pid parent-id]
        (if-let [[new-pc new-pid] (parent persistence dataset pc pid)]
          (recur (conj path [new-pc new-pid]) new-pc new-pid)
          path))
      (list))))

(defn root [persistence dataset collection id]
  "Return [collection id] tuple with self if no other root"
  (let [path (path persistence dataset collection id)]
    (if (empty? path)
      [collection id]
      (first path))))

(def ^:dynamic *jdbc-schema* :featured)
(def ^:dynamic *jdbc-features* :feature)
