Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
node-sample
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
周韬
node-sample
Commits
0e2b0a16
Commit
0e2b0a16
authored
Dec 29, 2016
by
Evan You
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix memory leak (fix #88 & #93)
parent
28bc4d3d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
1 deletion
+5
-1
api.js
src/store/api.js
+3
-1
create-api-server.js
src/store/create-api-server.js
+2
-0
No files found.
src/store/api.js
View file @
0e2b0a16
...
@@ -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
()
}
}
...
...
src/store/create-api-server.js
View file @
0e2b0a16
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
({
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment