Mercurial > prosody-modules
annotate mod_storage_memory/mod_storage_memory.lua @ 1751:3f3a5daf31cc
mod_http_muc_log: Update template for changes in template engine
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 19 May 2015 16:45:51 +0200 |
parents | 59fdf4f12343 |
children | 54c8a0cb2996 |
rev | line source |
---|---|
1259
fa7e402fcdc1
mod_storage_memory: Simple in-memory only storage backend without persistence
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
1 |
fa7e402fcdc1
mod_storage_memory: Simple in-memory only storage backend without persistence
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
2 local memory = setmetatable({}, { |
fa7e402fcdc1
mod_storage_memory: Simple in-memory only storage backend without persistence
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
3 __index = function(t, k) |
fa7e402fcdc1
mod_storage_memory: Simple in-memory only storage backend without persistence
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
4 local store = module:shared(k) |
fa7e402fcdc1
mod_storage_memory: Simple in-memory only storage backend without persistence
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
5 t[k] = store; |
fa7e402fcdc1
mod_storage_memory: Simple in-memory only storage backend without persistence
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
6 return store; |
fa7e402fcdc1
mod_storage_memory: Simple in-memory only storage backend without persistence
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
7 end |
fa7e402fcdc1
mod_storage_memory: Simple in-memory only storage backend without persistence
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
8 }); |
fa7e402fcdc1
mod_storage_memory: Simple in-memory only storage backend without persistence
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
9 |
fa7e402fcdc1
mod_storage_memory: Simple in-memory only storage backend without persistence
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
10 local keyval_store = {}; |
fa7e402fcdc1
mod_storage_memory: Simple in-memory only storage backend without persistence
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
11 keyval_store.__index = keyval_store; |
fa7e402fcdc1
mod_storage_memory: Simple in-memory only storage backend without persistence
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
12 |
fa7e402fcdc1
mod_storage_memory: Simple in-memory only storage backend without persistence
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
13 function keyval_store:get(username) |
fa7e402fcdc1
mod_storage_memory: Simple in-memory only storage backend without persistence
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
14 return self.store[username]; |
fa7e402fcdc1
mod_storage_memory: Simple in-memory only storage backend without persistence
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
15 end |
fa7e402fcdc1
mod_storage_memory: Simple in-memory only storage backend without persistence
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
16 |
fa7e402fcdc1
mod_storage_memory: Simple in-memory only storage backend without persistence
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
17 function keyval_store:set(username, data) |
fa7e402fcdc1
mod_storage_memory: Simple in-memory only storage backend without persistence
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
18 self.store[username] = data; |
fa7e402fcdc1
mod_storage_memory: Simple in-memory only storage backend without persistence
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
19 return true; |
fa7e402fcdc1
mod_storage_memory: Simple in-memory only storage backend without persistence
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
20 end |
fa7e402fcdc1
mod_storage_memory: Simple in-memory only storage backend without persistence
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
21 |
1607
8b997d9cf09e
mod_storage_memory: Add support for map stores
Kim Alvefur <zash@zash.se>
parents:
1259
diff
changeset
|
22 local map_store = {}; |
8b997d9cf09e
mod_storage_memory: Add support for map stores
Kim Alvefur <zash@zash.se>
parents:
1259
diff
changeset
|
23 map_store.__index = map_store; |
8b997d9cf09e
mod_storage_memory: Add support for map stores
Kim Alvefur <zash@zash.se>
parents:
1259
diff
changeset
|
24 |
8b997d9cf09e
mod_storage_memory: Add support for map stores
Kim Alvefur <zash@zash.se>
parents:
1259
diff
changeset
|
25 function map_store:get(username, key) |
8b997d9cf09e
mod_storage_memory: Add support for map stores
Kim Alvefur <zash@zash.se>
parents:
1259
diff
changeset
|
26 local userstore = self.store[username]; |
8b997d9cf09e
mod_storage_memory: Add support for map stores
Kim Alvefur <zash@zash.se>
parents:
1259
diff
changeset
|
27 if type(userstore) == "table" then |
8b997d9cf09e
mod_storage_memory: Add support for map stores
Kim Alvefur <zash@zash.se>
parents:
1259
diff
changeset
|
28 return userstore[key]; |
8b997d9cf09e
mod_storage_memory: Add support for map stores
Kim Alvefur <zash@zash.se>
parents:
1259
diff
changeset
|
29 end |
8b997d9cf09e
mod_storage_memory: Add support for map stores
Kim Alvefur <zash@zash.se>
parents:
1259
diff
changeset
|
30 end |
8b997d9cf09e
mod_storage_memory: Add support for map stores
Kim Alvefur <zash@zash.se>
parents:
1259
diff
changeset
|
31 |
8b997d9cf09e
mod_storage_memory: Add support for map stores
Kim Alvefur <zash@zash.se>
parents:
1259
diff
changeset
|
32 function map_store:set(username, key, data) |
8b997d9cf09e
mod_storage_memory: Add support for map stores
Kim Alvefur <zash@zash.se>
parents:
1259
diff
changeset
|
33 local userstore = self.store[username]; |
8b997d9cf09e
mod_storage_memory: Add support for map stores
Kim Alvefur <zash@zash.se>
parents:
1259
diff
changeset
|
34 if userstore == nil then |
8b997d9cf09e
mod_storage_memory: Add support for map stores
Kim Alvefur <zash@zash.se>
parents:
1259
diff
changeset
|
35 userstore = {}; |
8b997d9cf09e
mod_storage_memory: Add support for map stores
Kim Alvefur <zash@zash.se>
parents:
1259
diff
changeset
|
36 self.store[username] = userstore; |
8b997d9cf09e
mod_storage_memory: Add support for map stores
Kim Alvefur <zash@zash.se>
parents:
1259
diff
changeset
|
37 end |
8b997d9cf09e
mod_storage_memory: Add support for map stores
Kim Alvefur <zash@zash.se>
parents:
1259
diff
changeset
|
38 userstore[key] = data; |
8b997d9cf09e
mod_storage_memory: Add support for map stores
Kim Alvefur <zash@zash.se>
parents:
1259
diff
changeset
|
39 return true; |
8b997d9cf09e
mod_storage_memory: Add support for map stores
Kim Alvefur <zash@zash.se>
parents:
1259
diff
changeset
|
40 end |
8b997d9cf09e
mod_storage_memory: Add support for map stores
Kim Alvefur <zash@zash.se>
parents:
1259
diff
changeset
|
41 |
1608
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
42 local archive_store = {}; |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
43 archive_store.__index = archive_store; |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
44 |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
45 function archive_store:append(username, key, when, with, value) |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
46 local a = self.store[username]; |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
47 if not a then |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
48 a = {}; |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
49 self.store[username] = a; |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
50 end |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
51 local i = #a+1; |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
52 local v = { key = key, when = when, with = with, value = value }; |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
53 if not key or a[key] then |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
54 key = tostring(a):match"%x+$"..tostring(v):match"%x+$"; |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
55 v.key = key; |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
56 end |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
57 a[i] = v; |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
58 a[key] = i; |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
59 return true; |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
60 end |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
61 |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
62 local function archive_iter (a, start, stop, step, limit, when_start, when_end, match_with) |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
63 local item, when, with; |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
64 local count = 0; |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
65 coroutine.yield(true); -- Ready |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
66 for i = start, stop, step do |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
67 item = a[i]; |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
68 when, with = item.when, item.with; |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
69 if when >= when_start and when_end >= when and (not match_with or match_with == with) then |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
70 coroutine.yield(item.key, item.value, when, with); |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
71 count = count + 1; |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
72 if limit and count >= limit then return end |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
73 end |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
74 end |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
75 end |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
76 |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
77 function archive_store:find(username, query) |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
78 local a = self.store[username] or {}; |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
79 local start, stop, step = 1, #a, 1; |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
80 local qstart, qend, qwith = -math.huge, math.huge; |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
81 local limit; |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
82 if query then |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
83 module:log("debug", "query included") |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
84 if query.reverse then |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
85 start, stop, step = stop, start, -1; |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
86 if query.before then |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
87 start = a[query.before]; |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
88 end |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
89 elseif query.after then |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
90 start = a[query.after]; |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
91 end |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
92 limit = query.limit; |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
93 qstart = query.start or qstart; |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
94 qend = query["end"] or qend; |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
95 end |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
96 if not start then return nil, "invalid-key"; end |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
97 local iter = coroutine.wrap(archive_iter); |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
98 iter(a, start, stop, step, limit, qstart, qend, qwith); |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
99 return iter; |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
100 end |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
101 |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
102 function archive_store:delete(username, query) |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
103 if not query or next(query) == nil then |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
104 self.store[username] = nil; |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
105 return true; |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
106 end |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
107 local old = self.store[username]; |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
108 if not old then return true; end |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
109 local qstart = query.start or -math.huge; |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
110 local qend = query["end"] or math.huge; |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
111 local qwith = query.with; |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
112 local new = {}; |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
113 self.store[username] = new; |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
114 local t; |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
115 for i = 1, #old do |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
116 i = old[i]; |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
117 t = i.when; |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
118 if not(qstart >= t and qend <= t and (not qwith or i.with == qwith)) then |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
119 self:append(username, i.key, t, i.with, i.value); |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
120 end |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
121 end |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
122 if #new == 0 then |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
123 self.store[username] = nil; |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
124 end |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
125 return true; |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
126 end |
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
127 |
1259
fa7e402fcdc1
mod_storage_memory: Simple in-memory only storage backend without persistence
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
128 local stores = { |
fa7e402fcdc1
mod_storage_memory: Simple in-memory only storage backend without persistence
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
129 keyval = keyval_store; |
1607
8b997d9cf09e
mod_storage_memory: Add support for map stores
Kim Alvefur <zash@zash.se>
parents:
1259
diff
changeset
|
130 map = map_store; |
1608
59fdf4f12343
mod_storage_memory: Add support for archive stores
Kim Alvefur <zash@zash.se>
parents:
1607
diff
changeset
|
131 archive = archive_store; |
1259
fa7e402fcdc1
mod_storage_memory: Simple in-memory only storage backend without persistence
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
132 } |
fa7e402fcdc1
mod_storage_memory: Simple in-memory only storage backend without persistence
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
133 |
fa7e402fcdc1
mod_storage_memory: Simple in-memory only storage backend without persistence
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
134 local driver = {}; |
fa7e402fcdc1
mod_storage_memory: Simple in-memory only storage backend without persistence
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
135 |
fa7e402fcdc1
mod_storage_memory: Simple in-memory only storage backend without persistence
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
136 function driver:open(store, typ) |
fa7e402fcdc1
mod_storage_memory: Simple in-memory only storage backend without persistence
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
137 local store_mt = stores[typ or "keyval"]; |
fa7e402fcdc1
mod_storage_memory: Simple in-memory only storage backend without persistence
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
138 if store_mt then |
fa7e402fcdc1
mod_storage_memory: Simple in-memory only storage backend without persistence
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
139 return setmetatable({ store = memory[store] }, store_mt); |
fa7e402fcdc1
mod_storage_memory: Simple in-memory only storage backend without persistence
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
140 end |
fa7e402fcdc1
mod_storage_memory: Simple in-memory only storage backend without persistence
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
141 return nil, "unsupported-store"; |
fa7e402fcdc1
mod_storage_memory: Simple in-memory only storage backend without persistence
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
142 end |
fa7e402fcdc1
mod_storage_memory: Simple in-memory only storage backend without persistence
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
143 |
fa7e402fcdc1
mod_storage_memory: Simple in-memory only storage backend without persistence
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
144 module:provides("storage", driver); |