Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3494578
D6550.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D6550.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
Fri, Dec 20, 6:13 AM (19 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2680653
Default Alt Text
D6550.diff (2 KB)
Attached To
Mode
D6550: [lib] Store expirationTime instead of cacheInsertionTime in ENSCache
Attached
Detach File
Event Timeline
Log In to Comment