cache ^
creates a cache with the following properties
v 3.0
(defn cache
([data]
(cache data {}))
([data {:keys [tag display type] :as metadata
:or {type :atom}}]
(try
(let [cls (common/container type)
state (common/create cls data nil)]
(Cache. state (assoc metadata :type type)))
(catch java.lang.IllegalArgumentException e
(throw (ex-info "Invalid cache type:"
{:type type
:options (set (keys (.getMethodTable protocol.state/-container-state)))}))))))
link
(-> (cache {} {:tag "stuff" :type :ref}) (.state)) => clojure.lang.Ref (str (cache {:a 1 :b 2} {:type :agent})) => "#cache:agent{:a 1, :b 2}"