Skip to content

Cache missing token properties for one minute - #1648

Open
stefangutica wants to merge 7 commits into
developmentfrom
missing-token-properties-ttl
Open

stefangutica wants to merge 7 commits into
developmentfrom
missing-token-properties-ttl

Conversation

@stefangutica

@stefangutica stefangutica commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Reasoning

  • When a token was not found, for example in a transaction read from the pool before the token is indexed, null was cached like any other value. It stayed 1 hour for the token transfer properties and 1 week for the esdt properties read from the gateway.
  • No warmer or invalidation refreshes these keys. Until they expired, transaction actions and operations showed that token without name, ticker, decimals or svgUrl.

Proposed Changes

  • getTokenTransferProperties and getEsdtTokenProperties keep getOrSet, so concurrent misses still share one load and Redis hits are still kept in memory. They now pass cacheNullable: false, and when the raw method returns null the loader caches it for one minute itself.
  • getTokenTransferPropertiesFromLogs keeps batchApplyAll, now over the distinct identifiers. The batch caches the existing tokens with the standard ttl, and the missing ones are cached as null for one minute with setMany.
  • getEsdtTokenPropertiesRawFromElastic returns null when the token is not in Elastic, like the gateway source, instead of failing in the mapping.
  • getEsdtTokenProperties uses the CacheInfo.EsdtProperties ttl (one day) instead of the hardcoded one week.

How to test

  • npx jest src/test/unit/services/token.transfer.properties.spec.ts
  • Request a transaction that transfers a token that does not exist yet. The token is cached as null for one minute: check TTL token:transfer:properties:v2:<identifier> and TTL esdt:v2:<identifier> in Redis.
  • Once the token exists, the same transaction shows the token name, ticker and decimals within about two minutes at most, since each of the two cache layers can keep the null for one minute.
  • For an existing token, the ttl is unchanged: one hour for the token transfer properties and one day for the esdt properties.

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

k6 load testing comparison.
Base Commit Hash: c533f21
Target Commit Hash: fbe8f80

Metric Base Target Diff
AvgMax9095AvgMax9095AvgMax9095
Accounts34.301373.7544.8947.6642.67878.3357.3960.87+24.40% 🔴-36.06% ✅+27.86% 🔴+27.71% 🔴
Nodes33.26273.4344.5547.6961.1615976.6556.9459.44+83.93% 🔴+5743.15% 🔴+27.82% 🔴+24.65% 🔴
Mex33.62554.8544.6847.6638.70516.3051.2057.32+15.12% 🔴-6.95% ✅+14.61% 🔴+20.27% 🔴
Blocks54.033632.2647.0650.6761.503160.1158.8863.18+13.82% 🔴-13.00% ✅+25.12% 🔴+24.69% 🔴
Tokens33.42273.5444.6847.7638.89736.4651.2057.32+16.37% 🔴+169.24% 🔴+14.59% 🔴+20.03% 🔴
Transactions46.023927.9946.7550.0671.8212492.2761.4271.57+56.06% 🔴+218.03% 🔴+31.37% 🔴+42.96% 🔴
Pool33.30273.3044.6647.6738.93804.4551.2257.32+16.89% 🔴+194.35% 🔴+14.70% 🔴+20.25% 🔴
Test Run Duration60002.8560002.27

Legend: Avg - Average Response Time, Max - Maximum Response Time, 90 - 90th Percentile, 95 - 95th Percentile
All times are in milliseconds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant