Skip to content

Instantly share code, notes, and snippets.

@evilsneer
Created May 14, 2019 10:32
Show Gist options
  • Save evilsneer/6d214f315a2c697a22880b4df43b674f to your computer and use it in GitHub Desktop.
Save evilsneer/6d214f315a2c697a22880b4df43b674f to your computer and use it in GitHub Desktop.
persistents for Clojure
(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))))
@evilsneer
Copy link
Author

use as

init

(def holder (atom (or (<disk "filename.edn") {}))

save

(>disk "filename.edn" {:a 1})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment