Skip to content

Commit 8663db0

Browse files
committed
chg: [server] Cache module list JSON
1 parent c6d5e19 commit 8663db0

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

misp_modules/__init__.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -174,17 +174,22 @@ class ListModules(tornado.web.RequestHandler):
174174
global loaded_modules
175175
global mhandlers
176176

177+
_cached_json = None
178+
177179
def get(self):
178-
ret = []
179-
for module_name in loaded_modules:
180-
ret.append({
181-
'name': module_name,
182-
'type': mhandlers['type:' + module_name],
183-
'mispattributes': mhandlers[module_name].introspection(),
184-
'meta': mhandlers[module_name].version()
185-
})
180+
if not self._cached_json:
181+
ret = []
182+
for module_name in loaded_modules:
183+
ret.append({
184+
'name': module_name,
185+
'type': mhandlers['type:' + module_name],
186+
'mispattributes': mhandlers[module_name].introspection(),
187+
'meta': mhandlers[module_name].version()
188+
})
189+
self._cached_json = json.dumps(ret)
190+
186191
log.debug('MISP ListModules request')
187-
self.write(json.dumps(ret))
192+
self.write(self._cached_json)
188193

189194

190195
class QueryModule(tornado.web.RequestHandler):

0 commit comments

Comments
 (0)