Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33307259
D6550.1768797306.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D6550.1768797306.diff
View Options
diff --git a/lib/utils/ens-cache.js b/lib/utils/ens-cache.js
--- a/lib/utils/ens-cache.js
+++ b/lib/utils/ens-cache.js
@@ -12,13 +12,13 @@
type ENSNameQueryCacheEntry = {
// We normalize ETH addresses to lowercase characters
+normalizedETHAddress: string,
- +cacheInsertionTime: number,
+ +expirationTime: number,
// We normalize ENS names using eth-ens-namehash
+normalizedENSName: ?string | Promise<?string>,
};
type ENSAddressQueryCacheEntry = {
+normalizedENSName: string,
- +cacheInsertionTime: number,
+ +expirationTime: number,
+normalizedETHAddress: ?string | Promise<?string>,
};
@@ -85,7 +85,7 @@
this.nameQueryCache.set(normalizedETHAddress, {
normalizedETHAddress,
- cacheInsertionTime: Date.now(),
+ expirationTime: Date.now() + cacheTimeout,
normalizedENSName: fetchENSNamePromise,
});
@@ -93,7 +93,7 @@
const normalizedENSName = await fetchENSNamePromise;
this.nameQueryCache.set(normalizedETHAddress, {
normalizedETHAddress,
- cacheInsertionTime: Date.now(),
+ expirationTime: Date.now() + cacheTimeout,
normalizedENSName,
});
return normalizedENSName;
@@ -108,8 +108,8 @@
return undefined;
}
- const { cacheInsertionTime } = cacheResult;
- if (cacheInsertionTime + cacheTimeout <= Date.now()) {
+ const { expirationTime } = cacheResult;
+ if (expirationTime <= Date.now()) {
this.nameQueryCache.delete(normalizedETHAddress);
return undefined;
}
@@ -152,7 +152,7 @@
this.addressQueryCache.set(normalizedENSName, {
normalizedENSName,
- cacheInsertionTime: Date.now(),
+ expirationTime: Date.now() + cacheTimeout,
normalizedETHAddress: fetchETHAddressPromise,
});
@@ -160,7 +160,7 @@
const normalizedETHAddress = await fetchETHAddressPromise;
this.addressQueryCache.set(normalizedENSName, {
normalizedENSName,
- cacheInsertionTime: Date.now(),
+ expirationTime: Date.now() + cacheTimeout,
normalizedETHAddress,
});
return normalizedETHAddress;
@@ -178,8 +178,8 @@
return undefined;
}
- const { cacheInsertionTime } = cacheResult;
- if (cacheInsertionTime + cacheTimeout <= Date.now()) {
+ const { expirationTime } = cacheResult;
+ if (expirationTime <= Date.now()) {
this.addressQueryCache.delete(normalizedENSName);
return undefined;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Jan 19, 4:35 AM (16 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5954364
Default Alt Text
D6550.1768797306.diff (2 KB)
Attached To
Mode
D6550: [lib] Store expirationTime instead of cacheInsertionTime in ENSCache
Attached
Detach File
Event Timeline
Log In to Comment