From 76ed6399c4bd4636f1814e545ca4121e7ba5dc39 Mon Sep 17 00:00:00 2001 From: Sebastian Martinez Date: Thu, 8 Feb 2024 06:05:21 -0300 Subject: [PATCH] Remove caching projects found status --- package-lock.json | 9 --------- package.json | 1 - src/lib/cache.ts | 21 -------------------- src/lib/projects.ts | 10 +--------- src/views/projects/Header/ShareButton.svelte | 4 ++-- src/views/projects/Sidebar.svelte | 6 +++--- 6 files changed, 6 insertions(+), 45 deletions(-) delete mode 100644 src/lib/cache.ts diff --git a/package-lock.json b/package-lock.json index 40468d673..cf64384a7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,6 @@ "hast-util-to-dom": "^4.0.0", "hast-util-to-html": "^9.0.0", "lodash": "^4.17.21", - "lru-cache": "^10.1.0", "marked": "^11.1.1", "marked-katex-extension": "^5.0.0", "marked-linkify-it": "^3.1.8", @@ -3304,14 +3303,6 @@ "get-func-name": "^2.0.1" } }, - "node_modules/lru-cache": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.1.0.tgz", - "integrity": "sha512-/1clY/ui8CzjKFyjdvwPWJUYKiFVXG2I2cY0ssG7h4+hwk+XOIX7ZSG9Q7TW8TW3Kp3BUSqgFWBLgL4PJ+Blag==", - "engines": { - "node": "14 || >=16.14" - } - }, "node_modules/magic-string": { "version": "0.30.5", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.5.tgz", diff --git a/package.json b/package.json index 3b02c8051..eb2bc3643 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,6 @@ "hast-util-to-dom": "^4.0.0", "hast-util-to-html": "^9.0.0", "lodash": "^4.17.21", - "lru-cache": "^10.1.0", "marked": "^11.1.1", "marked-katex-extension": "^5.0.0", "marked-linkify-it": "^3.1.8", diff --git a/src/lib/cache.ts b/src/lib/cache.ts deleted file mode 100644 index 4be20b98f..000000000 --- a/src/lib/cache.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { LRUCache } from "lru-cache"; - -export function cached( - f: (...args: Args) => Promise, - makeKey: (...args: Args) => string, - options?: LRUCache.Options, -): (...args: Args) => Promise { - const cache = new LRUCache(options || { max: 500 }); - return async function (...args: Args): Promise { - const key = makeKey(...args); - const cached = cache.get(key); - - if (cached === undefined) { - const value = await f(...args); - cache.set(key, { value }); - return value; - } else { - return cached.value; - } - }; -} diff --git a/src/lib/projects.ts b/src/lib/projects.ts index 00bde6e42..21fd4d7b2 100644 --- a/src/lib/projects.ts +++ b/src/lib/projects.ts @@ -2,7 +2,6 @@ import type { BaseUrl, Project } from "@httpd-client"; import { HttpdClient } from "@httpd-client"; import { isFulfilled } from "@app/lib/utils"; -import { cached } from "./cache"; import { fetchLastCommit, loadProjectActivity, @@ -61,14 +60,7 @@ export async function getProjectsListingData(projects: ProjectBaseUrl[]) { }); } -export const cacheQueryProject = cached( - queryProject, - (baseUrl: BaseUrl, projectId: string) => - JSON.stringify({ baseUrl, projectId }), - { max: 200, ttl: 60 * 60 * 1000 }, -); - -async function queryProject( +export async function queryProject( baseUrl: BaseUrl, projectId: string, ): Promise<"found" | "notFound"> { diff --git a/src/views/projects/Header/ShareButton.svelte b/src/views/projects/Header/ShareButton.svelte index 92483429f..2548cb9db 100644 --- a/src/views/projects/Header/ShareButton.svelte +++ b/src/views/projects/Header/ShareButton.svelte @@ -1,7 +1,7 @@