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