Mercurial > prosody-modules
changeset 1607:8b997d9cf09e
mod_storage_memory: Add support for map stores
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 12 Feb 2015 15:13:50 +0100 |
parents | 2c8b985ebde5 |
children | 59fdf4f12343 |
files | mod_storage_memory/mod_storage_memory.lua |
diffstat | 1 files changed, 21 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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 = {};