Skip to content

Commit

Permalink
Revert "fix(cache): Switch to lru-cache to save ourselves from unlimi…
Browse files Browse the repository at this point in the history
…ted memory consumption"

This reverts commit e518222.

#38 (comment)

Will un-revert in semver-major bump.
  • Loading branch information
isaacs committed Aug 12, 2019
1 parent 96a49ea commit 4f193b3
Show file tree
Hide file tree
Showing 3 changed files with 1,026 additions and 796 deletions.
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
var url = require('url')
var gitHosts = require('./git-host-info.js')
var GitHost = module.exports = require('./git-host.js')
var LRU = require('lru-cache')
var cache = new LRU({max: 1000})

var protocolToRepresentationMap = {
'git+ssh:': 'sshurl',
Expand All @@ -24,15 +22,17 @@ var authProtocols = {
'git+http:': true
}

var cache = {}

module.exports.fromUrl = function (giturl, opts) {
if (typeof giturl !== 'string') return
var key = giturl + JSON.stringify(opts || {})

if (!cache.has(key)) {
cache.set(key, fromUrl(giturl, opts))
if (!(key in cache)) {
cache[key] = fromUrl(giturl, opts)
}

return cache.get(key)
return cache[key]
}

function fromUrl (giturl, opts) {
Expand Down
Loading

0 comments on commit 4f193b3

Please sign in to comment.