Move caching decision to the usecase layer

This commit is contained in:
behnam 2024-11-01 18:03:11 +03:00
parent 43a622851d
commit 0cb29f0b5f
3 changed files with 2 additions and 3 deletions

View File

@ -17,8 +17,6 @@ type customerDbResponse = {
export default class CustomerDbRepo implements CustomerRepo {
async fetchList(query: string): Promise<Customer[]> {
// This is equivalent to in fetch(..., {cache: 'no-store'}).
connection()
try {
const data = await sql`
SELECT

View File

@ -4,8 +4,10 @@ import serverDi from "@/feature/common/server-di";
import { customerKey } from "@/feature/core/customer/customer-key";
import Customer from "@/feature/core/customer/domain/entity/customer";
import CustomerRepo, { customerRepoKey } from "@/feature/core/customer/domain/i-repo/customer-repo";
import { connection } from "next/server";
export default async function fetchCustomersUsecase(query: string): Promise<Customer[]> {
connection()
const repo = serverDi(customerKey).resolve<CustomerRepo>(customerRepoKey)
return repo.fetchList(query)

View File

@ -10,7 +10,6 @@ export type RevenueDbResponse = {
};
export default class RevenueDbRepo implements RevenueRepo {
async fetchRevenues(): Promise<Revenue[]> {
// This is equivalent to in fetch(..., {cache: 'no-store'}).
try {
// Artificially delay a response for demo purposes.
// Don't do this in production :)