Mercurial > prosody-modules
comparison mod_storage_lmdb/mod_storage_lmdb.lua @ 1982:bb0b2eae5563
mod_storage_lmdb: Be consistent with argument name
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sat, 19 Dec 2015 00:25:30 +0100 |
| parents | 1f815f57fa57 |
| children | f7fc5088b340 |
comparison
equal
deleted
inserted
replaced
| 1981:1f815f57fa57 | 1982:bb0b2eae5563 |
|---|---|
| 57 | 57 |
| 58 local keyval = {}; | 58 local keyval = {}; |
| 59 local keyval_mt = { __index = keyval, flags = lmdb.MDB_CREATE }; | 59 local keyval_mt = { __index = keyval, flags = lmdb.MDB_CREATE }; |
| 60 drivers.keyval = keyval_mt; | 60 drivers.keyval = keyval_mt; |
| 61 | 61 |
| 62 function keyval:set(user, value) | 62 function keyval:set(key, value) |
| 63 if type(value) == "table" and next(value) == nil then | 63 if type(value) == "table" and next(value) == nil then |
| 64 value = nil; | 64 value = nil; |
| 65 end | 65 end |
| 66 if value ~= nil then | 66 if value ~= nil then |
| 67 value = serialize(value); | 67 value = serialize(value); |
| 68 end | 68 end |
| 69 return transaction(self.env, keyvalue_set, self.db, user, value); | 69 return transaction(self.env, keyvalue_set, self.db, key, value); |
| 70 end | 70 end |
| 71 | 71 |
| 72 function keyval:get(user) | 72 function keyval:get(key) |
| 73 local ok, data = transaction(self.env, keyvalue_get, self.db, user); | 73 local ok, data = transaction(self.env, keyvalue_get, self.db, key); |
| 74 if not ok then return ok, data; end | 74 if not ok then return ok, data; end |
| 75 return deserialize(data); | 75 return deserialize(data); |
| 76 end | 76 end |
| 77 | 77 |
| 78 function provider:init(config) | 78 function provider:init(config) |
