summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorunwox <me@unwox.com>2024-10-17 14:32:27 +0600
committerunwox <me@unwox.com>2024-10-17 14:32:27 +0600
commit359790c402d2731b7dd1df8a629726e69922a035 (patch)
tree6b6fc8110cefc76fccea51069a17e54bf22bd30c /lib
parent08370b6f302f93cae01b0521f29a62c20e97bdab (diff)
cache fixes for spelling mistakes
Diffstat (limited to 'lib')
-rw-r--r--lib/cache.fnl9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/cache.fnl b/lib/cache.fnl
index 8cf7323..76ede13 100644
--- a/lib/cache.fnl
+++ b/lib/cache.fnl
@@ -21,4 +21,11 @@
[(.. prefix "%")]))
(must (luna.db.exec-tx tx "DELETE FROM cache" []))))
-{: get :set _set : clear-tx}
+(fn wrap [db key f]
+ (local cached (get db key))
+ (if cached
+ cached
+ (let [res (f)]
+ (if res (_set db key res) nil))))
+
+{: get :set _set : clear-tx : wrap}