-
Notifications
You must be signed in to change notification settings - Fork 0
/
connection.lisp
36 lines (29 loc) · 963 Bytes
/
connection.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
;;; connection.lisp
(in-package #:CL-OHM)
(eval-when (:compile-toplevel :load-toplevel :execute)
(defvar *default-connection-parameters*
(list :host (vector 127 0 0 1)
:port 6379
:auth nil))
(defvar *connection-parameters* *default-connection-parameters*))
(defun setup-redis-connection (&key
(host #(127 0 0 1))
(port 6379)
auth)
"Configure Redis backend."
(setf (getf *connection-parameters* :host) host
(getf *connection-parameters* :port) port
(getf *connection-parameters* :auth) auth)
*connection-parameters*)
(defmacro with-connection (() &body body)
`(redis:with-connection ,*connection-parameters*
,@body))
(defmacro with-transaction (&body body)
`(progn
(red:multi)
,@body
(red:exec)))
(defun flush-db ()
"Erase the data store."
(with-connection ()
(red:flushdb)))