mirror of
https://github.com/umami-software/umami.git
synced 2026-02-05 21:27:20 +01:00
Updated redis logic.
This commit is contained in:
parent
39e7ceac06
commit
4d6ec631f7
9 changed files with 52 additions and 46 deletions
|
|
@ -1,14 +1,12 @@
|
|||
import { Website, Session } from '@prisma/client';
|
||||
import { getClient, redisEnabled } from '@umami/redis-client';
|
||||
import redis from '@/lib/redis';
|
||||
import { getWebsiteSession, getWebsite } from '@/queries';
|
||||
|
||||
export async function fetchWebsite(websiteId: string): Promise<Website> {
|
||||
let website = null;
|
||||
|
||||
if (redisEnabled) {
|
||||
const redis = getClient();
|
||||
|
||||
website = await redis.fetch(`website:${websiteId}`, () => getWebsite(websiteId), 86400);
|
||||
if (redis.enabled) {
|
||||
website = await redis.client.fetch(`website:${websiteId}`, () => getWebsite(websiteId), 86400);
|
||||
} else {
|
||||
website = await getWebsite(websiteId);
|
||||
}
|
||||
|
|
@ -23,10 +21,8 @@ export async function fetchWebsite(websiteId: string): Promise<Website> {
|
|||
export async function fetchSession(websiteId: string, sessionId: string): Promise<Session> {
|
||||
let session = null;
|
||||
|
||||
if (redisEnabled) {
|
||||
const redis = getClient();
|
||||
|
||||
session = await redis.fetch(
|
||||
if (redis.enabled) {
|
||||
session = await redis.client.fetch(
|
||||
`session:${sessionId}`,
|
||||
() => getWebsiteSession(websiteId, sessionId),
|
||||
86400,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue