Software /
code /
prosody-modules
File
mod_storage_memory/mod_storage_memory.lua @ 1485:d8c50448d0e7
mod_throttle_presence: Remove timer support, depend on mod_csi to enable/disable. Untested, but the previous version was definitely broken anyway.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 15 Aug 2014 19:46:44 +0100 |
parent | 1259:fa7e402fcdc1 |
child | 1607:8b997d9cf09e |
line wrap: on
line source
local memory = setmetatable({}, { __index = function(t, k) local store = module:shared(k) t[k] = store; return store; end }); local keyval_store = {}; keyval_store.__index = keyval_store; function keyval_store:get(username) return self.store[username]; end function keyval_store:set(username, data) self.store[username] = data; return true; end local stores = { keyval = keyval_store; } local driver = {}; function driver:open(store, typ) local store_mt = stores[typ or "keyval"]; if store_mt then return setmetatable({ store = memory[store] }, store_mt); end return nil, "unsupported-store"; end module:provides("storage", driver);