Skip to content
This repository was archived by the owner on Sep 10, 2019. It is now read-only.

Commit 40b87ec

Browse files
authored
fix(cacheUtils): add exports/default export
* fix(cacheUtils): add default export * fix(cacheUtils): add named exports
1 parent 8d1c246 commit 40b87ec

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ node_modules
44
.vscode
55

66
# Don’t include the built files
7+
/cacheUtils.js
78
/defaultLogger.js
89
/GraphQLConnector.js
910
/GraphQLModel.js

src/cacheUtils.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const getCustomCacheOptions = (connector, options) => {
2121
* @param {object} response the data to be cached
2222
* @return {object} the response, unchanged
2323
*/
24-
const addToCache = (connector, key, uri, options, response) => {
24+
export const addToCache = (connector, key, uri, options, response) => {
2525
if (!connector.enableCache) {
2626
return;
2727
}
@@ -53,7 +53,7 @@ const addToCache = (connector, key, uri, options, response) => {
5353
* @param {function} errorCB typically a Promise's `reject` function
5454
* @return {boolean} true if cached data was found, false otherwise
5555
*/
56-
const getCached = (connector, key, successCB, errorCB) => {
56+
export const getCached = (connector, key, successCB, errorCB) => {
5757
connector.redis.get(key, (error, data) => {
5858
if (error) {
5959
errorCB(error);
@@ -71,7 +71,7 @@ const getCached = (connector, key, successCB, errorCB) => {
7171
});
7272
};
7373

74-
const isCacheEnabled = (connector, options) => {
74+
export const isCacheEnabled = (connector, options) => {
7575
if (!connector.redis || !connector.enableCache) {
7676
return false;
7777
}
@@ -81,12 +81,13 @@ const isCacheEnabled = (connector, options) => {
8181
return true;
8282
};
8383

84-
const refreshCache = (connector, uri, options, key) => {
84+
export const refreshCache = (connector, uri, options, key) => {
8585
connector.redis.get(`${REFRESH_CACHE_PREFIX_KEY}${key}`, (error, data) => {
8686
if (data !== 'true') {
8787
//Key expired, means it's time to refresh cache;
8888
connector.makeRequest(uri, options, key);
8989
}
9090
});
9191
};
92-
export { addToCache, isCacheEnabled, getCached, refreshCache };
92+
93+
export default { addToCache, isCacheEnabled, getCached, refreshCache };

0 commit comments

Comments
 (0)