# HG changeset patch # User Kim Alvefur # Date 1423750430 -3600 # Node ID 8b997d9cf09eb6402e93cf13ea34de1c70d02d6c # Parent 2c8b985ebde53abfd15137710c0740bcdc889316 mod_storage_memory: Add support for map stores diff -r 2c8b985ebde5 -r 8b997d9cf09e mod_storage_memory/mod_storage_memory.lua --- a/mod_storage_memory/mod_storage_memory.lua Tue Feb 10 15:00:10 2015 +0100 +++ b/mod_storage_memory/mod_storage_memory.lua Thu Feb 12 15:13:50 2015 +0100 @@ -19,8 +19,29 @@ return true; end +local map_store = {}; +map_store.__index = map_store; + +function map_store:get(username, key) + local userstore = self.store[username]; + if type(userstore) == "table" then + return userstore[key]; + end +end + +function map_store:set(username, key, data) + local userstore = self.store[username]; + if userstore == nil then + userstore = {}; + self.store[username] = userstore; + end + userstore[key] = data; + return true; +end + local stores = { keyval = keyval_store; + map = map_store; } local driver = {};