feat: completely remove redis

This commit is contained in:
2025-01-06 16:14:29 +01:00
parent d3009ac315
commit 53c4d5b129
24 changed files with 629 additions and 311 deletions

View File

@ -1,8 +1,8 @@
import { HandlerContext } from "$fresh/server.ts";
import { FreshContext } from "$fresh/server.ts";
import { getMovieCredits } from "@lib/tmdb.ts";
import * as cache from "@lib/cache/cache.ts";
import { json } from "@lib/helpers.ts";
import { createLogger } from "@lib/log.ts";
import { createCache } from "@lib/cache.ts";
type CachedMovieCredits = {
lastUpdated: number;
@ -10,12 +10,13 @@ type CachedMovieCredits = {
};
const CACHE_INTERVAL = 1000 * 60 * 24 * 30;
const cache = createCache<CachedMovieCredits>({ expires: CACHE_INTERVAL });
const log = createLogger("api/tmdb");
export const handler = async (
_req: Request,
_ctx: HandlerContext,
_ctx: FreshContext,
) => {
const id = _ctx.params.id;
@ -29,7 +30,7 @@ export const handler = async (
const cacheId = `/movie/credits/${id}`;
const cachedResponse = await cache.get<CachedMovieCredits>(cacheId);
const cachedResponse = cache.get(cacheId);
if (
cachedResponse && Date.now() < (cachedResponse.lastUpdated + CACHE_INTERVAL)
) {