newsnow/server/hooks/useCache.ts

14 lines
416 B
TypeScript
Raw Normal View History

2024-10-23 03:11:20 +08:00
import process from "node:process"
2024-10-17 04:33:52 +08:00
import { Cache } from "#/database/cache"
export function useCache() {
try {
const db = useDatabase()
2024-10-23 03:18:50 +08:00
if (process.env.CF_PAGES_BRANCH && process.env.CF_PAGES_BRANCH !== "production") return
if (process.env.NODE_ENV && process.env.NODE_ENV !== "production") return
if (db) return new Cache(db)
2024-10-17 04:33:52 +08:00
} catch (e) {
logger.error("failed to init database ", e)
}
}