mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 01:51:40 -05:00
Enable Engine caching
This commit is contained in:
parent
68351674da
commit
574f08c449
2 changed files with 23 additions and 16 deletions
|
@ -24,10 +24,12 @@ export const getDefaultResolvers = (collectionName, resolverOptions = defaultOpt
|
|||
async resolver(root, {terms = {}}, context, { cacheControl }) {
|
||||
|
||||
debug(`//--------------- start ${collectionName} list resolver ---------------//`);
|
||||
debug(resolverOptions);
|
||||
debug(terms);
|
||||
|
||||
if (cacheControl && resolverOptions.enableCache) {
|
||||
cacheControl.setCacheHint({ maxAge: resolverOptions.cacheMaxAge });
|
||||
const maxAge = resolverOptions.cacheMaxAge || defaultOptions.cacheMaxAge;
|
||||
cacheControl.setCacheHint({ maxAge });
|
||||
}
|
||||
|
||||
// get currentUser and Users collection from context
|
||||
|
@ -74,7 +76,8 @@ export const getDefaultResolvers = (collectionName, resolverOptions = defaultOpt
|
|||
debug(documentId);
|
||||
|
||||
if (cacheControl && resolverOptions.enableCache) {
|
||||
cacheControl.setCacheHint({ maxAge: resolverOptions.cacheMaxAge });
|
||||
const maxAge = resolverOptions.cacheMaxAge || defaultOptions.cacheMaxAge;
|
||||
cacheControl.setCacheHint({ maxAge });
|
||||
}
|
||||
|
||||
const { currentUser, Users } = context;
|
||||
|
@ -108,7 +111,8 @@ export const getDefaultResolvers = (collectionName, resolverOptions = defaultOpt
|
|||
async resolver(root, {terms}, context, { cacheControl }) {
|
||||
|
||||
if (cacheControl && resolverOptions.enableCache) {
|
||||
cacheControl.setCacheHint({ maxAge: resolverOptions.cacheMaxAge });
|
||||
const maxAge = resolverOptions.cacheMaxAge || defaultOptions.cacheMaxAge;
|
||||
cacheControl.setCacheHint({ maxAge });
|
||||
}
|
||||
|
||||
const collection = context[collectionName];
|
||||
|
|
|
@ -34,14 +34,14 @@ const engineConfig = {
|
|||
// }
|
||||
// }
|
||||
// ],
|
||||
// "stores": [
|
||||
// {
|
||||
// "name": "embeddedCache",
|
||||
// "inMemory": {
|
||||
// "cacheSize": 10485760
|
||||
// }
|
||||
// }
|
||||
// ],
|
||||
"stores": [
|
||||
{
|
||||
"name": "vulcanCache",
|
||||
"inMemory": {
|
||||
"cacheSize": 20000000
|
||||
}
|
||||
}
|
||||
],
|
||||
// "sessionAuth": {
|
||||
// "store": "embeddedCache",
|
||||
// "header": "Authorization"
|
||||
|
@ -50,13 +50,16 @@ const engineConfig = {
|
|||
// {
|
||||
// "host": "127.0.0.1",
|
||||
// "port": 3000,
|
||||
// "endpoint": "/graphql"
|
||||
// "endpoint": "/graphql",
|
||||
// "extensions": {
|
||||
// "strip": []
|
||||
// }
|
||||
// }
|
||||
// ],
|
||||
// "queryCache": {
|
||||
// "publicFullQueryStore": "embeddedCache",
|
||||
// "privateFullQueryStore": "embeddedCache"
|
||||
// },
|
||||
"queryCache": {
|
||||
"publicFullQueryStore": "vulcanCache",
|
||||
"privateFullQueryStore": "vulcanCache"
|
||||
},
|
||||
// "reporting": {
|
||||
// "endpointUrl": "https://engine-report.apollographql.com",
|
||||
// "debugReports": true
|
||||
|
|
Loading…
Add table
Reference in a new issue