Software /
code /
prosody-modules
Annotate
mod_storage_gdbm/mod_storage_gdbm.lua @ 1628:5e4b37b9cde1
mod_storage_gdbm: Fix traceback if query is nil or no metadata exists
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 25 Mar 2015 17:29:54 +0100 |
parent | 1604:53052a610c67 |
child | 1629:36eb0dbea7ba |
rev | line source |
---|---|
1570
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
1 -- mod_storage_gdbm |
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
2 -- Copyright (C) 2014 Kim Alvefur |
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
3 -- |
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
4 -- This file is MIT/X11 licensed. |
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
5 -- |
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
6 -- Depends on lgdbm: |
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
7 -- http://webserver2.tecgraf.puc-rio.br/~lhf/ftp/lua/#lgdbm |
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
8 |
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
9 local gdbm = require"gdbm"; |
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
10 local path = require"util.paths"; |
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
11 local lfs = require"lfs"; |
1596
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
12 local uuid = require"util.uuid".generate; |
1593
d9f3c66ea938
mod_storage_gdbm: Use require directly instead of util.import (which is not available in prosodyctl, breaks adduser etc)
Kim Alvefur <zash@zash.se>
parents:
1570
diff
changeset
|
13 local serialization = require"util.serialization"; |
1596
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
14 local st = require"util.stanza"; |
1593
d9f3c66ea938
mod_storage_gdbm: Use require directly instead of util.import (which is not available in prosodyctl, breaks adduser etc)
Kim Alvefur <zash@zash.se>
parents:
1570
diff
changeset
|
15 local serialize = serialization.serialize; |
d9f3c66ea938
mod_storage_gdbm: Use require directly instead of util.import (which is not available in prosodyctl, breaks adduser etc)
Kim Alvefur <zash@zash.se>
parents:
1570
diff
changeset
|
16 local deserialize = serialization.deserialize; |
1570
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
17 |
1628
5e4b37b9cde1
mod_storage_gdbm: Fix traceback if query is nil or no metadata exists
Kim Alvefur <zash@zash.se>
parents:
1604
diff
changeset
|
18 local empty = {}; |
5e4b37b9cde1
mod_storage_gdbm: Fix traceback if query is nil or no metadata exists
Kim Alvefur <zash@zash.se>
parents:
1604
diff
changeset
|
19 |
1596
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
20 local function id(v) return v; end |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
21 |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
22 local function is_stanza(s) |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
23 return getmetatable(s) == st.stanza_mt; |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
24 end |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
25 |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
26 local function ifelse(cond, iftrue, iffalse) |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
27 if cond then return iftrue; end return iffalse; |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
28 end |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
29 |
1570
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
30 local base_path = path.resolve_relative_path(prosody.paths.data, module.host); |
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
31 lfs.mkdir(base_path); |
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
32 |
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
33 local cache = {}; |
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
34 |
1595
6288591d5edf
mod_storage_gdbm: Prepare for supporting multiple store types
Kim Alvefur <zash@zash.se>
parents:
1593
diff
changeset
|
35 local keyval = {}; |
6288591d5edf
mod_storage_gdbm: Prepare for supporting multiple store types
Kim Alvefur <zash@zash.se>
parents:
1593
diff
changeset
|
36 local keyval_mt = { __index = keyval, suffix = ".db" }; |
1570
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
37 |
1595
6288591d5edf
mod_storage_gdbm: Prepare for supporting multiple store types
Kim Alvefur <zash@zash.se>
parents:
1593
diff
changeset
|
38 function keyval:set(user, value) |
1570
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
39 local ok, err = gdbm.replace(self._db, user or "@", serialize(value)); |
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
40 if not ok then return nil, err; end |
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
41 return true; |
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
42 end |
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
43 |
1595
6288591d5edf
mod_storage_gdbm: Prepare for supporting multiple store types
Kim Alvefur <zash@zash.se>
parents:
1593
diff
changeset
|
44 function keyval:get(user) |
1570
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
45 local data, err = gdbm.fetch(self._db, user or "@"); |
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
46 if not data then return nil, err; end |
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
47 return deserialize(data); |
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
48 end |
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
49 |
1596
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
50 local archive = {}; |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
51 local archive_mt = { __index = archive, suffix = ".adb" }; |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
52 |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
53 archive.get = keyval.get; |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
54 archive.set = keyval.set; |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
55 |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
56 function archive:append(username, key, when, with, value) |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
57 key = key or uuid(); |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
58 local meta = self:get(username); |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
59 if not meta then |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
60 meta = {}; |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
61 end |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
62 local i = meta[key] or #meta+1; |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
63 local type; |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
64 if is_stanza(value) then |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
65 type, value = "stanza", st.preserialize(value); |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
66 end |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
67 meta[i] = { key = key, when = when, with = with, type = type }; |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
68 meta[key] = i; |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
69 local ok, err = self:set(username, meta); |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
70 if not ok then return nil, err; end |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
71 ok, err = self:set(key, value); |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
72 if not ok then return nil, err; end |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
73 return key; |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
74 end |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
75 |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
76 local deserialize = { |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
77 stanza = st.deserialize; |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
78 }; |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
79 |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
80 function archive:find(username, query) |
1628
5e4b37b9cde1
mod_storage_gdbm: Fix traceback if query is nil or no metadata exists
Kim Alvefur <zash@zash.se>
parents:
1604
diff
changeset
|
81 query = query or empty_query; |
5e4b37b9cde1
mod_storage_gdbm: Fix traceback if query is nil or no metadata exists
Kim Alvefur <zash@zash.se>
parents:
1604
diff
changeset
|
82 local meta = self:get(username) or empty; |
1596
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
83 local r = query.reverse; |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
84 local d = r and -1 or 1; |
1602
3912a53fd4db
mod_storage_gdbm: Get 'after' parameter from correct table
Kim Alvefur <zash@zash.se>
parents:
1596
diff
changeset
|
85 local s = meta[ifelse(r, query.before, query.after)]; |
1603
1fbec16996f5
mod_storage_gdbm: Add support for 'limit' query parameter
Kim Alvefur <zash@zash.se>
parents:
1602
diff
changeset
|
86 local limit = query.limit; |
1596
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
87 if s then |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
88 s = s + d; |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
89 else |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
90 s = ifelse(r, #meta, 1) |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
91 end |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
92 local e = ifelse(r, 1, #meta); |
1603
1fbec16996f5
mod_storage_gdbm: Add support for 'limit' query parameter
Kim Alvefur <zash@zash.se>
parents:
1602
diff
changeset
|
93 local c = 0; |
1596
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
94 return function () |
1603
1fbec16996f5
mod_storage_gdbm: Add support for 'limit' query parameter
Kim Alvefur <zash@zash.se>
parents:
1602
diff
changeset
|
95 if limit and c >= limit then return end |
1596
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
96 local item, value; |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
97 for i = s, e, d do |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
98 item = meta[i]; |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
99 if (not query.with or item.with == query.with) |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
100 and (not query.start or item.when >= query.start) |
1604
53052a610c67
mod_storage_gdbm: Fix comparison of 'end'
Kim Alvefur <zash@zash.se>
parents:
1603
diff
changeset
|
101 and (not query["end"] or item.when <= query["end"]) then |
1603
1fbec16996f5
mod_storage_gdbm: Add support for 'limit' query parameter
Kim Alvefur <zash@zash.se>
parents:
1602
diff
changeset
|
102 s = i + d; c = c + 1; |
1596
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
103 value = self:get(item.key); |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
104 return item.key, (deserialize[item.type] or id)(value), item.when, item.with; |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
105 end |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
106 end |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
107 end |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
108 end |
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
109 |
1595
6288591d5edf
mod_storage_gdbm: Prepare for supporting multiple store types
Kim Alvefur <zash@zash.se>
parents:
1593
diff
changeset
|
110 local drivers = { |
6288591d5edf
mod_storage_gdbm: Prepare for supporting multiple store types
Kim Alvefur <zash@zash.se>
parents:
1593
diff
changeset
|
111 keyval = keyval_mt; |
1596
b362e6c00fd1
mod_storage_gdbm: Add archive support
Kim Alvefur <zash@zash.se>
parents:
1595
diff
changeset
|
112 archive = archive_mt; |
1595
6288591d5edf
mod_storage_gdbm: Prepare for supporting multiple store types
Kim Alvefur <zash@zash.se>
parents:
1593
diff
changeset
|
113 } |
6288591d5edf
mod_storage_gdbm: Prepare for supporting multiple store types
Kim Alvefur <zash@zash.se>
parents:
1593
diff
changeset
|
114 |
1570
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
115 function open(_, store, typ) |
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
116 typ = typ or "keyval"; |
1595
6288591d5edf
mod_storage_gdbm: Prepare for supporting multiple store types
Kim Alvefur <zash@zash.se>
parents:
1593
diff
changeset
|
117 local driver_mt = drivers[typ]; |
6288591d5edf
mod_storage_gdbm: Prepare for supporting multiple store types
Kim Alvefur <zash@zash.se>
parents:
1593
diff
changeset
|
118 if not driver_mt then |
1570
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
119 return nil, "unsupported-store"; |
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
120 end |
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
121 |
1595
6288591d5edf
mod_storage_gdbm: Prepare for supporting multiple store types
Kim Alvefur <zash@zash.se>
parents:
1593
diff
changeset
|
122 local db_path = path.join(base_path, store) .. driver_mt.suffix; |
1570
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
123 |
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
124 local db = cache[db_path]; |
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
125 if not db then |
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
126 db = assert(gdbm.open(db_path, "c")); |
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
127 cache[db_path] = db; |
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
128 end |
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
129 return setmetatable({ _db = db; _path = db_path; store = store, typ = type }, driver_mt); |
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
130 end |
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
131 |
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
132 function module.unload() |
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
133 for path, db in pairs(cache) do |
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
134 gdbm.sync(db); |
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
135 gdbm.close(db); |
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
136 end |
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
137 end |
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
138 |
67fafebdceb7
mod_storage_gdbm: Storage backend based on lgdbm
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
139 module:provides"storage"; |