From 08370b6f302f93cae01b0521f29a62c20e97bdab Mon Sep 17 00:00:00 2001 From: unwox Date: Thu, 17 Oct 2024 14:31:22 +0600 Subject: implement cache clearing by namespaces --- lib/cache.fnl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib/cache.fnl') diff --git a/lib/cache.fnl b/lib/cache.fnl index b21a05e..8cf7323 100644 --- a/lib/cache.fnl +++ b/lib/cache.fnl @@ -15,7 +15,10 @@ [key value])) value) -(fn clear-tx [tx] - (must (luna.db.exec-tx tx "DELETE FROM cache" []))) +(fn clear-tx [tx prefix] + (if (= "string" (type prefix)) + (must (luna.db.exec-tx tx "DELETE FROM cache WHERE key LIKE ?" + [(.. prefix "%")])) + (must (luna.db.exec-tx tx "DELETE FROM cache" [])))) {: get :set _set : clear-tx} -- cgit v1.2.3