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

Added token cache reset interval of one week #3038

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 5 additions & 3 deletions packages/frontend/src/services/indexer/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ export class IndexerCache extends Cache {
accountId,
kind,
updater,
timeoutNs
timeoutNs,
resetNs,
}) {
const record = await this._getRecord(accountId, kind);

Expand All @@ -127,7 +128,7 @@ export class IndexerCache extends Cache {
// If the version is updated on the helper
// we should rescan from the beginning of the blockchain
const isVersionChanged = version !== record.data.version;
if (isVersionChanged) {
if (isVersionChanged || this._shouldUpdate(lastTimestamp, resetNs)) {
record.timestamp = 0;
shouldRestart = true;
}
Expand All @@ -142,7 +143,8 @@ export class IndexerCache extends Cache {
accountId,
kind,
updater,
timeoutNs
timeoutNs,
resetNs,
});
}

Expand Down
2 changes: 2 additions & 0 deletions packages/frontend/src/services/indexer/cached-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Cache from './cache';


const UPDATE_REQUEST_INTERVAL_NS = 1000 * 30 * 1000000;
const RESET_REQUEST_INTERVAL_NS = 1000 * 604800 * 1000000;
const LIKELY_NFT_KEY = 'likelyNFTs';
const LIKELY_TOKENS_KEY = 'likelyTokens';

Expand All @@ -21,6 +22,7 @@ export default {
kind: LIKELY_TOKENS_KEY,
updater: (timestamp) => api.listLikelyTokens(accountId, timestamp),
timeoutNs: UPDATE_REQUEST_INTERVAL_NS,
resetNs: RESET_REQUEST_INTERVAL_NS,
});
}
};