Commit 0e2b0a16 authored by Evan You's avatar Evan You

fix memory leak (fix #88 & #93)

parent 28bc4d3d
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
import api from 'create-api' import api from 'create-api'
// warm the front page cache every 15 min // warm the front page cache every 15 min
if (api.cachedIds) { // make sure to do this only once across all requests
if (api.onServer && !api.warmCacheStarted) {
api.warmCacheStarted = true
warmCache() warmCache()
} }
......
import Firebase from 'firebase' import Firebase from 'firebase'
import LRU from 'lru-cache' import LRU from 'lru-cache'
import { fetchItems } from './api'
let api let api
const config = { const config = {
...@@ -12,6 +13,7 @@ if (process.__API__) { ...@@ -12,6 +13,7 @@ if (process.__API__) {
} else { } else {
Firebase.initializeApp(config) Firebase.initializeApp(config)
api = process.__API__ = Firebase.database().ref(version) api = process.__API__ = Firebase.database().ref(version)
api.onServer = true
// fetched item cache // fetched item cache
api.cachedItems = LRU({ api.cachedItems = LRU({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment