From f2413e147654886107094029c3ac41342bfbcdcb Mon Sep 17 00:00:00 2001 From: cel Date: Wed, 15 Mar 2017 13:02:05 -0400 Subject: live-invalidate about cache --- lib/app.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'lib/app.js') diff --git a/lib/app.js b/lib/app.js index c4683d7..ee2ec39 100644 --- a/lib/app.js +++ b/lib/app.js @@ -31,7 +31,8 @@ function App(sbot, config) { sbot.get = memo({cache: lru(100)}, sbot.get) this.getMsg = memo({cache: lru(100)}, getMsgWithValue, sbot) - this.getAbout = memo({cache: lru(100)}, getAbout.bind(this), sbot, sbot.id) + this.getAbout = memo({cache: this.aboutCache = lru(100)}, + getAbout.bind(this), sbot, sbot.id) this.unboxContent = memo({cache: lru(100)}, sbot.private.unbox) this.reverseNameCache = lru(100) @@ -47,6 +48,16 @@ App.prototype.go = function () { }).listen(self.port, self.host, function () { self.log('Listening on http://' + self.host + ':' + self.port) }) + + // invalidate cached About info when new About messages come in + pull( + self.sbot.links({rel: 'about', old: false, values: true}), + pull.drain(function (link) { + self.aboutCache.remove(link.dest) + }, function (err) { + if (err) self.error('about:', err) + }) + ) } var logPrefix = '[' + pkg.name + ']' -- cgit v1.2.3