comparison plugins/mod_storage_memory.lua @ 11274:ecbfde402364

mod_storage_memory: Support full ID range queries
author Kim Alvefur <zash@zash.se>
date Tue, 12 Jan 2021 16:58:10 +0100
parents c55bd98a54f8
children 1256f32f21b6
comparison
equal deleted inserted replaced
11273:9f1355689648 11274:ecbfde402364
55 55
56 archive_store.caps = { 56 archive_store.caps = {
57 total = true; 57 total = true;
58 quota = archive_item_limit; 58 quota = archive_item_limit;
59 truncate = true; 59 truncate = true;
60 full_id_range = true;
60 }; 61 };
61 62
62 function archive_store:append(username, key, value, when, with) 63 function archive_store:append(username, key, value, when, with)
63 if is_stanza(value) then 64 if is_stanza(value) then
64 value = st.preserialize(value); 65 value = st.preserialize(value);
140 end 141 end
141 if not found then 142 if not found then
142 return nil, "item-not-found"; 143 return nil, "item-not-found";
143 end 144 end
144 end 145 end
145 elseif query.before then 146 last_key = query.after;
146 last_key = query.before;
147 elseif query.after then 147 elseif query.after then
148 local found = false; 148 local found = false;
149 for j = 1, #items do 149 for j = 1, #items do
150 if (items[j].key or tostring(j)) == query.after then 150 if (items[j].key or tostring(j)) == query.after then
151 found = true; 151 found = true;
154 end 154 end
155 end 155 end
156 if not found then 156 if not found then
157 return nil, "item-not-found"; 157 return nil, "item-not-found";
158 end 158 end
159 last_key = query.before;
160 elseif query.before then
161 last_key = query.before;
159 end 162 end
160 if query.limit and #items - i > query.limit then 163 if query.limit and #items - i > query.limit then
161 items[i+query.limit+1] = nil; 164 items[i+query.limit+1] = nil;
162 end 165 end
163 end 166 end