Skip to content

Commit

Permalink
Merge branch 'cache-clear' of https://github.com/biothings/bte-server
Browse files Browse the repository at this point in the history
…into dev
  • Loading branch information
tokebe committed Dec 11, 2023
2 parents 738278e + b26ac71 commit 6f704b8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion data/predicates.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion data/smartapi_specs.json

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions src/controllers/cron/clear_edge_cache.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const { redisClient } = require("@biothings-explorer/query_graph_handler");
const Debug = require("debug");
const cron = require("node-cron");
const debug = Debug("bte:biothings-explorer-trapi:cron");

module.exports = () => {
cron.schedule("0 0 * * *", async () => {
debug("Checking status for edge cache clearing.");
if (!redisClient.clientEnabled) {
debug("Cache not enabled, skipping edge cache clearing");
return;
}
debug("Redis client enabled, proceeding with cache clearing.");
await redisClient.client.usingLock(["redisLock:EdgeCaching"], 600000, () => {
redisClient.client.clearEdgeCache();
});
});
};
2 changes: 2 additions & 0 deletions src/controllers/cron/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const smartapiCron = require("./update_local_smartapi");
const cacheClearCron = require("./clear_edge_cache");

module.exports = () => {
smartapiCron();
cacheClearCron();
};

0 comments on commit 6f704b8

Please sign in to comment.