Since Korma/C3PO seems to be bad about cleaning up its connection pools, this function is
memoized and will return an existing connection pool on subsequent calls."
(let[db->korma-db(fn[database]
(log/debug(color/red"Creating a new DB connection..."))
(kdb/create-db(db->connection-specdatabase)))
memoized-db->korma-db(memoizedb->korma-db)]
(fn[{{:keys[short-lived?]}:details,:asdatabase}]
;; Use un-memoized version of function for so-called "short-lived" databases (i.e. temporary ones that we won't create a connection pool for)
((ifshort-lived?
db->korma-db
memoized-db->korma-db)(select-keysdatabase[:engine:details]))))); only :engine and :details are needed for driver/connection so just pass those so memoization works as expected