git ssb

30+

cel / git-ssb-web



Commit 0f2544504b14876c399f700cc5d0c2d8d240bdf6

Limit caching of repos and messages with LRU

cel committed on 11/21/2016, 3:31:01 AM
Parent: 32940fafc150e939c305d3accdb18f10aa7172c8

Files changed

index.jschanged
package.jsonchanged
index.jsView
@@ -23,8 +23,9 @@
2323 var many = require('pull-many')
2424 var ident = require('pull-identify-filetype')
2525 var mime = require('mime-types')
2626 var moment = require('moment')
27 +var LRUCache = require('lrucache')
2728
2829 var hlCssPath = path.resolve(require.resolve('highlight.js'), '../../styles')
2930 var emojiPath = path.resolve(require.resolve('emoji-named-characters'), '../pngs')
3031
@@ -113,12 +114,14 @@
113114 this.logLevel = this.logLevels.indexOf(config.logging.level)
114115 this.ssbAppname = config.appname || 'ssb'
115116 this.isPublic = config.public
116117 this.getVotes = require('./lib/votes')(ssb)
117- this.getMsg = asyncMemo(ssb.get)
118 + this.getMsg = asyncMemo({cache: new LRUCache(100)}, ssb.get)
118119 this.issues = Issues.init(ssb)
119120 this.pullReqs = PullRequests.init(ssb)
120- this.getRepo = asyncMemo(function (id, cb) {
121 + this.getRepo = asyncMemo({
122 + cache: new LRUCache(32)
123 + }, function (id, cb) {
121124 this.getMsg(id, function (err, msg) {
122125 if (err) return cb(err)
123126 ssbGit.getRepo(ssb, {key: id, value: msg}, {live: true}, cb)
124127 })
package.jsonView
@@ -3,12 +3,13 @@
33 "version": "2.4.0",
44 "description": "web server for browsing git repos on ssb",
55 "bin": "server.js",
66 "dependencies": {
7- "asyncmemo": "^0.1.0",
7 + "asyncmemo": "^1.0.0",
88 "diff": "^2.2.3",
99 "emoji-named-characters": "^1.0.2",
1010 "highlight.js": "^9.2.0",
11 + "lrucache": "^1.0.2",
1112 "mime-types": "^2.1.12",
1213 "moment": "^2.14.1",
1314 "multicb": "^1.2.1",
1415 "node-polyglot": "^1.0.0",

Built with git-ssb-web