aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2012-02-21 23:24:24 +0100
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2012-02-21 23:24:24 +0100
commit8753798e196898e087bc2b33b15486aafc0e7363 (patch)
treeacdb364a7dcc1f0509092fe3912b3316df682aca /src
parenta57ba2aa0ba0c7140848b80f035999f02fac0bdc (diff)
Add docstrings.
Diffstat (limited to 'src')
-rw-r--r--src/eu/mulk/instadump.clj24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/eu/mulk/instadump.clj b/src/eu/mulk/instadump.clj
index fffc29e..704b37b 100644
--- a/src/eu/mulk/instadump.clj
+++ b/src/eu/mulk/instadump.clj
@@ -71,10 +71,17 @@
;;;; * Public API
-(defn setup-instadump! [dirname]
+(defn setup-instadump!
+ "Set up the Instadump database at the file system location indicated
+ by dirname."
+ [dirname]
(reset! dbenv (make-db-env dirname)))
-(defmacro defstate [sym default]
+(defmacro defstate
+ "Define a global ref managed by Instadump. The supplied default
+ value is used if the variable cannot be found in the database.
+ Otherwise, the value stored in the database is used."
+ [sym default]
(let [dbkey (str *ns* "/" (name sym))]
`(defonce ~sym
(let [r# (ref (with-db (getkey ~dbkey ~default)))]
@@ -82,13 +89,22 @@
r#))))
-(defn save-all-global-state! []
+(defn save-all-global-state!
+ "Direct Instadump to dump a snapshot of all variables created by
+ defstate into the database. save-all-global-state! runs in an
+ implicit transaction in order to ensure data consistency."
+ []
(with-db
(dosync
(doseq [[key r] @state-vars]
(putkey key (ensure r))))))
-(defn reload-all-global-state! []
+(defn reload-all-global-state!
+ "Direct Instadump to revert all variables created by defstate to the
+ state saved by the last invocation of save-all-global-state!. Will
+ fail if any variables cannot be restored (e.g. if some variables
+ have never been saved before)."
+ []
(with-db
(dosync
(doseq [[key r] @state-vars]