Software /
code /
prosody
Comparison
plugins/mod_storage_sql2.lua @ 6736:4aee55c0cc5c
mod_storage_sql2: Add some comments
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 24 Jun 2015 22:54:17 +0100 |
parent | 6532:a966efeb6cb3 |
child | 6737:9f932a31eeba |
comparison
equal
deleted
inserted
replaced
6735:b553a30620b2 | 6736:4aee55c0cc5c |
---|---|
190 end | 190 end |
191 end | 191 end |
192 return true; | 192 return true; |
193 end | 193 end |
194 | 194 |
195 --- Key/value store API (default store type) | |
196 | |
195 local keyval_store = {}; | 197 local keyval_store = {}; |
196 keyval_store.__index = keyval_store; | 198 keyval_store.__index = keyval_store; |
197 function keyval_store:get(username) | 199 function keyval_store:get(username) |
198 user,store = username,self.store; | 200 user,store = username,self.store; |
199 local ok, result = engine:transaction(keyval_store_get); | 201 local ok, result = engine:transaction(keyval_store_get); |
211 return engine:select("SELECT DISTINCT `user` FROM `prosody` WHERE `host`=? AND `store`=?", host, self.store); | 213 return engine:select("SELECT DISTINCT `user` FROM `prosody` WHERE `host`=? AND `store`=?", host, self.store); |
212 end); | 214 end); |
213 if not ok then return ok, result end | 215 if not ok then return ok, result end |
214 return iterator(result); | 216 return iterator(result); |
215 end | 217 end |
218 | |
219 --- Archive store API | |
216 | 220 |
217 local archive_store = {} | 221 local archive_store = {} |
218 archive_store.__index = archive_store | 222 archive_store.__index = archive_store |
219 function archive_store:append(username, key, when, with, value) | 223 function archive_store:append(username, key, when, with, value) |
220 if value == nil then -- COMPAT early versions | 224 if value == nil then -- COMPAT early versions |
340 local stores = { | 344 local stores = { |
341 keyval = keyval_store; | 345 keyval = keyval_store; |
342 archive = archive_store; | 346 archive = archive_store; |
343 }; | 347 }; |
344 | 348 |
349 --- Implement storage driver API | |
350 | |
351 -- FIXME: Some of these operations need to operate on the archive store(s) too | |
352 | |
345 local driver = {}; | 353 local driver = {}; |
346 | 354 |
347 function driver:open(store, typ) | 355 function driver:open(store, typ) |
348 local store_mt = stores[typ or "keyval"]; | 356 local store_mt = stores[typ or "keyval"]; |
349 if store_mt then | 357 if store_mt then |