diff options
author | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2017-03-15 13:02:05 -0400 |
---|---|---|
committer | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2017-03-15 13:02:05 -0400 |
commit | f2413e147654886107094029c3ac41342bfbcdcb (patch) | |
tree | b9f80de6b02790c3113f5b2a9d6736418310c571 | |
parent | 3c09de63bc13f224fe98dce2e402050d4006b9cb (diff) | |
download | patchfoo-f2413e147654886107094029c3ac41342bfbcdcb.tar.gz patchfoo-f2413e147654886107094029c3ac41342bfbcdcb.zip |
live-invalidate about cache
-rw-r--r-- | lib/app.js | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -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 + ']' |