Mercurial > prosody-modules
comparison mod_storage_memory/mod_storage_memory.lua @ 2655:f4353f959460
mod_storage_memory: Remove map store (rely on storagemanagers shiv)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 30 Mar 2017 23:38:40 +0200 |
parents | 9e5015555fff |
children | 83fb61fa476e |
comparison
equal
deleted
inserted
replaced
2654:9e5015555fff | 2655:f4353f959460 |
---|---|
27 self.store[username or NULL] = data; | 27 self.store[username or NULL] = data; |
28 return true; | 28 return true; |
29 end | 29 end |
30 | 30 |
31 keyval_store.purge = _purge_store; | 31 keyval_store.purge = _purge_store; |
32 | |
33 local map_store = {}; | |
34 map_store.__index = map_store; | |
35 | |
36 function map_store:get(username, key) | |
37 local userstore = self.store[username or NULL]; | |
38 if type(userstore) == "table" then | |
39 return userstore[key]; | |
40 end | |
41 end | |
42 | |
43 function map_store:set(username, key, data) | |
44 local userstore = self.store[username or NULL]; | |
45 if userstore == nil then | |
46 userstore = {}; | |
47 self.store[username or NULL] = userstore; | |
48 end | |
49 userstore[key] = data; | |
50 return true; | |
51 end | |
52 | |
53 map_store.remove = {}; | |
54 function map_store:set_keys(username, keydatas) | |
55 local userstore = self.store[username or NULL]; | |
56 if userstore == nil then | |
57 userstore = {}; | |
58 self.store[username or NULL] = userstore; | |
59 end | |
60 for k,v in pairs(keydatas) do | |
61 if v == self.remove then v = nil; end | |
62 userstore[k] = v; | |
63 end | |
64 return true; | |
65 end | |
66 | |
67 map_store.purge = _purge_store; | |
68 | 32 |
69 local archive_store = {}; | 33 local archive_store = {}; |
70 archive_store.__index = archive_store; | 34 archive_store.__index = archive_store; |
71 | 35 |
72 function archive_store:append(username, key, value, when, with) | 36 function archive_store:append(username, key, value, when, with) |
157 | 121 |
158 archive_store.purge = _purge_store; | 122 archive_store.purge = _purge_store; |
159 | 123 |
160 local stores = { | 124 local stores = { |
161 keyval = keyval_store; | 125 keyval = keyval_store; |
162 map = map_store; | |
163 archive = archive_store; | 126 archive = archive_store; |
164 } | 127 } |
165 | 128 |
166 local driver = {}; | 129 local driver = {}; |
167 | 130 |