Skip to content

Commit

Permalink
Perf: enforce more cache
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Dec 30, 2023
1 parent 1f23212 commit c85f9fa
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
11 changes: 10 additions & 1 deletion Build/build-apple-cdn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,19 @@ import { task, traceAsync } from './lib/trace-runner';
import { SHARED_DESCRIPTION } from './lib/constants';
import picocolors from 'picocolors';
import { createMemoizedPromise } from './lib/memo-promise';
import { TTL, deserializeArray, fsCache, serializeArray } from './lib/cache-filesystem';

export const getAppleCdnDomainsPromise = createMemoizedPromise(() => traceAsync(
picocolors.gray('download dnsmasq-china-list apple.china.conf'),
() => parseFelixDnsmasq('https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/apple.china.conf'),
() => fsCache.apply(
'https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/apple.china.conf',
() => parseFelixDnsmasq('https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/apple.china.conf'),
{
ttl: TTL.THREE_DAYS(),
serializer: serializeArray,
deserializer: deserializeArray
}
),
picocolors.gray
));

Expand Down
2 changes: 1 addition & 1 deletion Build/lib/cache-filesystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export const TTL = {
TEN_DAYS: () => randomInt(9, 11) * 24 * 60 * 60 * 1000
};

const separator = String.fromCharCode(0);
const separator = '\u0000';
// const textEncoder = new TextEncoder();
// const textDecoder = new TextDecoder();
// export const serializeString = (str: string) => textEncoder.encode(str);
Expand Down
11 changes: 6 additions & 5 deletions Build/lib/reject-data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export const HOSTS = [
['https://raw.githubusercontent.com/hoshsadiq/adblock-nocoin-list/master/hosts.txt', false, false, TTL.THREE_DAYS()],
// have not been updated for more than a year, so we set a 14 days cache ttl
['https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy.txt', true, false, TTL.TWO_WEEKS()],
['https://raw.githubusercontent.com/jerryn70/GoodbyeAds/master/Extension/GoodbyeAds-Xiaomi-Extension.txt', false],
['https://raw.githubusercontent.com/jerryn70/GoodbyeAds/master/Extension/GoodbyeAds-Huawei-Extension.txt', false],
['https://raw.githubusercontent.com/jerryn70/GoodbyeAds/master/Extension/GoodbyeAds-Xiaomi-Extension.txt', false, false, TTL.THREE_DAYS()],
['https://raw.githubusercontent.com/jerryn70/GoodbyeAds/master/Extension/GoodbyeAds-Huawei-AdBlock.txt', false, false, TTL.THREE_DAYS()],
// ad-wars is not actively maintained, so we set a 7 days cache ttl
['https://raw.githubusercontent.com/jdlingyu/ad-wars/master/hosts', false, false, TTL.ONE_WEEK()],
['https://raw.githubusercontent.com/durablenapkin/block/master/luminati.txt', true],
Expand Down Expand Up @@ -58,7 +58,7 @@ export const ADGUARD_FILTERS = [
'https://ublockorigin.github.io/uAssetsCDN/thirdparties/easylist.txt',
'https://ublockorigin.pages.dev/thirdparties/easylist.txt'
],
12 * 60 * 60 * 1000
TTL.TWLVE_HOURS()
],
// EasyPrivacy
[
Expand All @@ -70,15 +70,16 @@ export const ADGUARD_FILTERS = [
'https://ublockorigin.github.io/uAssetsCDN/thirdparties/easyprivacy.txt',
'https://ublockorigin.pages.dev/thirdparties/easyprivacy.txt'
],
12 * 60 * 60 * 1000
TTL.TWLVE_HOURS()
],
// AdGuard DNS Filter
[
'https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt',
[
'https://filters.adtidy.org/extension/ublock/filters/15_optimized.txt',
'https://adguardteam.github.io/HostlistsRegistry/assets/filter_1.txt'
]
],
TTL.TWLVE_HOURS()
],
// uBlock Origin Filter List
[
Expand Down

0 comments on commit c85f9fa

Please sign in to comment.