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