Skip to content

Commit 0e2b0a1

Browse files
committed
fix memory leak (fix vuejs#88 & vuejs#93)
1 parent 28bc4d3 commit 0e2b0a1

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/store/api.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
import api from 'create-api'
33

44
// warm the front page cache every 15 min
5-
if (api.cachedIds) {
5+
// make sure to do this only once across all requests
6+
if (api.onServer && !api.warmCacheStarted) {
7+
api.warmCacheStarted = true
68
warmCache()
79
}
810

src/store/create-api-server.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Firebase from 'firebase'
22
import LRU from 'lru-cache'
3+
import { fetchItems } from './api'
34

45
let api
56
const config = {
@@ -12,6 +13,7 @@ if (process.__API__) {
1213
} else {
1314
Firebase.initializeApp(config)
1415
api = process.__API__ = Firebase.database().ref(version)
16+
api.onServer = true
1517

1618
// fetched item cache
1719
api.cachedItems = LRU({

0 commit comments

Comments
 (0)