Mercurial > prosody-modules
comparison mod_storage_memory/mod_storage_memory.lua @ 2803:9db18f909b84
mod_storage_memory: Allow archive items to be overwritten by id
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Wed, 18 Oct 2017 20:25:48 +0200 |
| parents | 0d5d1ff96600 |
| children | 8e5da12205b5 |
comparison
equal
deleted
inserted
replaced
| 2802:0d5d1ff96600 | 2803:9db18f909b84 |
|---|---|
| 53 a = {}; | 53 a = {}; |
| 54 self.store[username or NULL] = a; | 54 self.store[username or NULL] = a; |
| 55 end | 55 end |
| 56 local i = #a+1; | 56 local i = #a+1; |
| 57 local v = { key = key, when = when, with = with, value = value }; | 57 local v = { key = key, when = when, with = with, value = value }; |
| 58 if not key or a[key] then | 58 if not key then |
| 59 key = tostring(a):match"%x+$"..tostring(v):match"%x+$"; | 59 key = tostring(a):match"%x+$"..tostring(v):match"%x+$"; |
| 60 v.key = key; | 60 v.key = key; |
| 61 end | |
| 62 if a[key] then | |
| 63 table.remove(a, a[key]); | |
| 61 end | 64 end |
| 62 a[i] = v; | 65 a[i] = v; |
| 63 a[key] = i; | 66 a[key] = i; |
| 64 return key; | 67 return key; |
| 65 end | 68 end |
