Created
May 14, 2019 10:32
-
-
Save evilsneer/6d214f315a2c697a22880b4df43b674f to your computer and use it in GitHub Desktop.
persistents for Clojure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns module.persistents | |
(:require [clojure.java.io :as io])) | |
(defn >disk [location data] | |
(spit location (pr-str data))) | |
(defn <disk [location] | |
(if (.exists (io/file location)) | |
(read-string (slurp cache-file)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
use as
init
(def holder (atom (or (<disk "filename.edn") {}))
save
(>disk "filename.edn" {:a 1})