mod_storage_memory: Add :purge() method to all store types

Tue, 14 Mar 2017 12:59:41 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Tue, 14 Mar 2017 12:59:41 +0000
changeset 2619
1e4bbff0a6fd
parent 2618
c6652d055ba3
child 2620
8b8cab2eb7fc

mod_storage_memory: Add :purge() method to all store types

mod_storage_memory/mod_storage_memory.lua file | annotate | diff | comparison | revisions
--- a/mod_storage_memory/mod_storage_memory.lua	Fri Mar 10 10:36:17 2017 +0000
+++ b/mod_storage_memory/mod_storage_memory.lua	Tue Mar 14 12:59:41 2017 +0000
@@ -9,6 +9,11 @@
 
 local NULL = {};
 
+local function _purge_store(self, username)
+	self.store[username or NULL] = nil;
+	return true;
+end
+
 local keyval_store = {};
 keyval_store.__index = keyval_store;
 
@@ -21,6 +26,8 @@
 	return true;
 end
 
+keyval_store.purge = _purge_store;
+
 local map_store = {};
 map_store.__index = map_store;
 
@@ -55,6 +62,8 @@
 	return true;
 end
 
+map_store.purge = _purge_store;
+
 local archive_store = {};
 archive_store.__index = archive_store;
 
@@ -144,6 +153,8 @@
 	return true;
 end
 
+archive_store.purge = _purge_store;
+
 local stores = {
 	keyval = keyval_store;
 	map = map_store;

mercurial