Software / code / prosody
Comparison
plugins/mod_storage_memory.lua @ 9881:68faa0c1a99c 0.11
mod_storage_memory: Implement :user iteration API
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Mon, 14 Jan 2019 00:17:02 +0100 |
| parent | 9838:40ed04014b97 |
| child | 9882:18f025b3987d |
comparison
equal
deleted
inserted
replaced
| 9880:78885b1bbb91 | 9881:68faa0c1a99c |
|---|---|
| 21 local function _purge_store(self, username) | 21 local function _purge_store(self, username) |
| 22 self.store[username or NULL] = nil; | 22 self.store[username or NULL] = nil; |
| 23 return true; | 23 return true; |
| 24 end | 24 end |
| 25 | 25 |
| 26 local function _users(self) | |
| 27 return next, self.store, nil; | |
| 28 end | |
| 29 | |
| 26 local keyval_store = {}; | 30 local keyval_store = {}; |
| 27 keyval_store.__index = keyval_store; | 31 keyval_store.__index = keyval_store; |
| 28 | 32 |
| 29 function keyval_store:get(username) | 33 function keyval_store:get(username) |
| 30 return (self.store[username or NULL] or NULL)(); | 34 return (self.store[username or NULL] or NULL)(); |
| 38 return true; | 42 return true; |
| 39 end | 43 end |
| 40 | 44 |
| 41 keyval_store.purge = _purge_store; | 45 keyval_store.purge = _purge_store; |
| 42 | 46 |
| 47 keyval_store.users = _users; | |
| 48 | |
| 43 local archive_store = {}; | 49 local archive_store = {}; |
| 44 archive_store.__index = archive_store; | 50 archive_store.__index = archive_store; |
| 51 | |
| 52 archive_store.users = _users; | |
| 45 | 53 |
| 46 function archive_store:append(username, key, value, when, with) | 54 function archive_store:append(username, key, value, when, with) |
| 47 if is_stanza(value) then | 55 if is_stanza(value) then |
| 48 value = st.preserialize(value); | 56 value = st.preserialize(value); |
| 49 value = envload("return xml"..serialize(value), "=(stanza)", { xml = st.deserialize }) | 57 value = envload("return xml"..serialize(value), "=(stanza)", { xml = st.deserialize }) |