Mercurial > prosody-modules
comparison mod_storage_appendmap/mod_storage_appendmap.lua @ 5690:ea6c18ec0669
mod_storage_appendmap: Implement item/user iteration methods
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sun, 05 Nov 2023 21:03:30 +0100 |
| parents | e44b868cc575 |
| children | 78f766372e2c |
comparison
equal
deleted
inserted
replaced
| 5689:09233b625cb9 | 5690:ea6c18ec0669 |
|---|---|
| 95 end | 95 end |
| 96 local data = serialize_pair(key, value); | 96 local data = serialize_pair(key, value); |
| 97 return dm.append_raw(user, module.host, self.store, "map", data); | 97 return dm.append_raw(user, module.host, self.store, "map", data); |
| 98 end | 98 end |
| 99 | 99 |
| 100 function map:items() | |
| 101 return dm.users(module.host, self.store, "map"); | |
| 102 end | |
| 103 | |
| 100 local keyval = { remove = REMOVE }; | 104 local keyval = { remove = REMOVE }; |
| 101 local keyval_mt = { __index = keyval }; | 105 local keyval_mt = { __index = keyval }; |
| 102 | 106 |
| 103 function keyval:get(user) | 107 function keyval:get(user) |
| 104 return map.get(self, user, nil); | 108 return map.get(self, user, nil); |
| 105 end | 109 end |
| 106 | 110 |
| 107 function keyval:set(user, keyvalues) | 111 function keyval:set(user, keyvalues) |
| 108 local data = serialize_map(keyvalues); | 112 local data = serialize_map(keyvalues); |
| 109 return dm.store_raw(dm.getpath(user, module.host, self.store, "map"), data); | 113 return dm.store_raw(dm.getpath(user, module.host, self.store, "map"), data); |
| 114 end | |
| 115 | |
| 116 function keyval:users() | |
| 117 return dm.users(module.host, self.store, "map"); | |
| 110 end | 118 end |
| 111 | 119 |
| 112 -- TODO some kind of periodic compaction thing? | 120 -- TODO some kind of periodic compaction thing? |
| 113 function map:_compact(user) | 121 function map:_compact(user) |
| 114 local data = self:get(user); | 122 local data = self:get(user); |
