Skip to content

Commit

Permalink
Add cache purging support to Docker container
Browse files Browse the repository at this point in the history
  • Loading branch information
dickwolff committed Feb 10, 2024
1 parent ce50f59 commit 2187cf7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,16 @@ The following parameters can be given to the Docker run command.
| `--env USE_POLLING=true` | Y | When set to true, the container will continously look for new files to process and the container will not stop. |
| `--env DEBUG_LOGGING=true` | Y | When set to true, the container will show logs in more detail, useful for error tracing. |
| `--env FORCE_DEGIRO_V2=true` | Y | When set to true, the converter will use the DEGIRO V2 converter (currently in beta) when a DEGIRO file was found. |
| `--env PURGE_CACHE=true` | Y | When set to true, the file cache will be purged on start. |

1: You can retrieve your Ghostfolio account ID by going to Accounts > select your account and copying the ID from the URL.

![image](https://user-images.githubusercontent.com/5620002/203353840-f5db7323-fb2f-4f4f-befc-e4e340466a74.png)

### Caching

The tool uses `cacache` to store data retrieved from Yahoo Finance inside the container. This way the load on Yahoo Finance is reduced and the tool should run faster. The cached data is stored inside the container in `tmp/e2g-cache`. If you feel you need to invalidate your cache, you can do so by adding `--env PURGE_CACHE=true` to your run command. This will clear the cache on container start, and the tool will recreate the cache the next time it has to retrieve data from Yahoo Finance.

</details>

## Run locally
Expand Down
11 changes: 11 additions & 0 deletions src/watcher.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
import path from "path";
import * as fs from "fs";
import chokidar from "chokidar";
import * as cacache from "cacache";
import * as matcher from "closest-match";
import { createAndRunConverter } from "./converter";

// Check if the cache should be purged.
if (Boolean(process.env.PURGE_CACHE)) {

console.log("[i] Purging cache (PURGE_CACHE set to true)..");
Promise.all([
cacache.rm("tmp/e2g-cache", "isinSymbolCache"),
cacache.rm("tmp/e2g-cache", "symbolCache")
]).then(() => console.log("[i] Cache purged!"));
}

// Define input and output.
const inputFolder = process.env.E2G_INPUT_FOLDER || "/var/e2g-input";
const outputFolder = process.env.E2G_OUTPUT_FOLDER || "/var/e2g-output";
Expand Down

0 comments on commit 2187cf7

Please sign in to comment.