Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve cache logic #190

Merged
merged 1 commit into from
Nov 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/components/refresh-data/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useToast } from "@/components/ui/use-toast";
import { Button } from "../ui/button";
import { ReloadIcon } from "@radix-ui/react-icons";
import { RefreshButtonLoadingContext } from "../index";
import { GateExchange } from '@/middlelayers/datafetch/coins/cex/gate'
import { CacheCenter } from '@/middlelayers/datafetch/utils/cache'

const retries = 3;
const retryInterval = 3000; // 3s
Expand Down Expand Up @@ -49,11 +49,14 @@ const App = ({
const handleButtonClick = () => {
setRefreshLoading(true);


let refreshError: Error | undefined;

retry(refreshAllData, retries, retryInterval)
.then(async () => updateAllCurrencyRates())
.then(async () => {
// clean cache after all analyzers finished successfully
CacheCenter.getInstance().clearCache();
return updateAllCurrencyRates();
})
.catch((err) => {
refreshError = err;
})
Expand Down
2 changes: 1 addition & 1 deletion src/middlelayers/charts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async function queryCoinsData(): Promise<(WalletCoin & {
}
const assets = await loadPortfolios(config)
// always query btc and usdt price
const priceMap = await queryCoinPrices(_(assets).map("symbol").push("USDT").push("BTC").uniq().value())
const priceMap = await queryCoinPrices(_(assets).map("symbol").push("USDT").push("BTC").uniq().compact().value())

let lastAssets = _.clone(assets)
const groupUSD: boolean = _(config).get(['configs', 'groupUSD']) || false
Expand Down
2 changes: 0 additions & 2 deletions src/middlelayers/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ async function loadPortfoliosByConfig(config: CexConfig & TokenConfig): Promise<
}, {
concurrency: anas.length,
})
// clean cache after all analyzers finished successfully
CacheCenter.getInstance().clearCache()
const assets = combineCoinLists(coinLists)
return assets
}
Expand Down
Loading