aboutsummaryrefslogtreecommitdiff
path: root/lib/app.js
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-03-15 13:02:05 -0400
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-03-15 13:02:05 -0400
commitf2413e147654886107094029c3ac41342bfbcdcb (patch)
treeb9f80de6b02790c3113f5b2a9d6736418310c571 /lib/app.js
parent3c09de63bc13f224fe98dce2e402050d4006b9cb (diff)
downloadpatchfoo-f2413e147654886107094029c3ac41342bfbcdcb.tar.gz
patchfoo-f2413e147654886107094029c3ac41342bfbcdcb.zip
live-invalidate about cache
Diffstat (limited to 'lib/app.js')
-rw-r--r--lib/app.js13
1 files changed, 12 insertions, 1 deletions
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 + ']'