changeset 1634:25441bd8b344

mod_storage_gdbm: Add purge action
author Kim Alvefur <zash@zash.se>
date Wed, 25 Mar 2015 17:45:53 +0100
parents 1d2dc6c74581
children b877b75eb973
files mod_storage_gdbm/mod_storage_gdbm.lua
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mod_storage_gdbm/mod_storage_gdbm.lua	Wed Mar 25 17:45:17 2015 +0100
+++ b/mod_storage_gdbm/mod_storage_gdbm.lua	Wed Mar 25 17:45:53 2015 +0100
@@ -151,6 +151,18 @@
 	return setmetatable({ _db = db; _path = db_path; store = store, typ = type }, driver_mt);
 end
 
+function purge(_, user)
+	for dir in lfs.dir(base_path) do
+		local name, ext = dir:match("^(.-)%.a?db$");
+		if ext == ".db" then
+			open(_, name, "keyval"):set(user, nil);
+		elseif ext == ".adb" then
+			open(_, name, "archive"):delete(user);
+		end
+	end
+	return true;
+end
+
 function module.unload()
 	for path, db in pairs(cache) do
 		gdbm.sync(db);