Path: blob/master/src/packages/frontend/compute/get-title.ts
1503 views
/*1Get title *and* color of a compute server you own.2This is mainly meant to be used for purchase history, etc.,3so the result is cached for a few minutes, and it's4an error if you don't own the server.5*/67import LRU from "lru-cache";8import { getTitle as getTitleViaApi } from "./api";910const cache = new LRU<11number,12{ title: string; color: string; project_specific_id: number }13>({14max: 1000,15ttl: 1000 * 30,16});1718export default async function getTitle(19compute_server_id: number,20): Promise<{ title: string; color: string; project_specific_id: number }> {21if (cache.has(compute_server_id)) {22return cache.get(compute_server_id)!;23}24const x = await getTitleViaApi({ id: compute_server_id });25cache.set(compute_server_id, x);26return x;27}282930