diff options
| author | unwox <me@unwox.com> | 2024-10-17 14:32:27 +0600 |
|---|---|---|
| committer | unwox <me@unwox.com> | 2024-10-17 14:32:27 +0600 |
| commit | 359790c402d2731b7dd1df8a629726e69922a035 (patch) | |
| tree | 6b6fc8110cefc76fccea51069a17e54bf22bd30c /lib/cache.fnl | |
| parent | 08370b6f302f93cae01b0521f29a62c20e97bdab (diff) | |
cache fixes for spelling mistakes
Diffstat (limited to 'lib/cache.fnl')
| -rw-r--r-- | lib/cache.fnl | 9 |
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} |
