mod_storage_sql: Compose a keyval+ store out of keyval and map store methods
authorKim Alvefur <zash@zash.se>
Sat, 10 Jun 2023 16:39:48 +0200
changeset 13148 033ea8b46d6a
parent 13147 3ec48555b773
child 13149 af251471d5ae
mod_storage_sql: Compose a keyval+ store out of keyval and map store methods Removes the need for the shim in storagemanager. The methods only really access the 'store' property of the first (self) argument, so this is safe.
plugins/mod_storage_sql.lua
--- a/plugins/mod_storage_sql.lua	Sat Jun 10 15:44:09 2023 +0200
+++ b/plugins/mod_storage_sql.lua	Sat Jun 10 16:39:48 2023 +0200
@@ -660,10 +660,27 @@
 	return iterator(result);
 end
 
+local keyvalplus = {
+	__index = {
+		-- keyval
+		get = keyval_store.get;
+		set = keyval_store.set;
+		items = keyval_store.users;
+		-- map
+		get_key = map_store.get;
+		set_key = map_store.set;
+		remove = map_store.remove;
+		set_keys = map_store.set_keys;
+		get_key_from_all = map_store.get_all;
+		delete_key_from_all = map_store.delete_all;
+	};
+}
+
 local stores = {
 	keyval = keyval_store;
 	map = map_store;
 	archive = archive_store;
+	["keyval+"] = keyvalplus;
 };
 
 --- Implement storage driver API