Skip to content

Commit 6e8fdcd

Browse files
authored
Change how minCacheTTL is set
- Change minCacheTTL from Math.min to Math.max - Change default value of cachettl from 1800 to 30.
1 parent 9711bc0 commit 6e8fdcd

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/content/docs/1.1.1.1/other-ways-to-use-1.1.1.1/dns-in-google-sheets.mdx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { Details } from "~/components"
1212
1.1.1.1 works directly inside Google Sheets. To get started, create a [Google Function](https://developers.google.com/apps-script/guides/sheets/functions) with the following code:
1313

1414
```js
15-
function NSLookup(type, domain, usecache = false, cachettl = 1800) {
15+
function NSLookup(type, domain, usecache = false, cachettl = 30) {
1616

1717
if (typeof type == 'undefined') {
1818
throw new Error('Missing parameter 1 dns type');
@@ -82,20 +82,17 @@ function NSLookup(type, domain, usecache = false, cachettl = 1800) {
8282
}
8383

8484
var outputData = [];
85+
var minCacheTTL = cachettl;
8586

8687
for (var i in response.Answer) {
8788
outputData.push(response.Answer[i].data);
89+
minCacheTTL = Math.max(minCacheTTL, response.Answer[i].TTL);
8890
}
8991

9092
var outputString = outputData.join(',');
9193

9294
if (usecache) {
93-
cache.put(cacheBinKey, outputString, cachettl);
94-
}
95-
96-
for (var i in response.Answer) {
97-
outputData.push(response.Answer[i].data);
98-
minCacheTTL = Math.min(minCacheTTL, response.Answer[i].TTL);
95+
cache.put(cacheBinKey, outputString, minCacheTTL);
9996
}
10097

10198
return outputString;

0 commit comments

Comments
 (0)