Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.
TypeScript analyticsaudience-segmentationchartscohort-analysisgoogle-analyticsproduct-analyticsstatisticsuser-journeyweb-analytics
Updated redis methods.
Mike Cao592c18190250
diff --git a/package.json b/package.jsonindex c72a054f7..bf5f00ae6 100644--- a/package.json+++ b/package.json@@ -71,7 +71,7 @@"@react-spring/web": "^9.7.3","@tanstack/react-query": "^5.28.6","@umami/prisma-client": "^0.14.0",- "@umami/redis-client": "^0.18.0",+ "@umami/redis-client": "^0.20.0","chalk": "^4.1.1","chart.js": "^4.4.2","chartjs-adapter-date-fns": "^3.0.0",diff --git a/src/lib/cache.ts b/src/lib/cache.tsindex 974824993..cb218ba0a 100644--- a/src/lib/cache.ts+++ b/src/lib/cache.ts@@ -3,57 +3,48 @@ import redis from '@umami/redis-client';import { getSession, getUser, getWebsite } from '../queries';async function fetchWebsite(websiteId: string): Promise<Website> {- return redis.client.getCache(`website:${websiteId}`, () => getWebsite(websiteId), 86400);+ return redis.client.fetch(`website:${websiteId}`, () => getWebsite(websiteId), 86400);}async function storeWebsite(data: { id: any }) {const { id } = data;const key = `website:${id}`;- const obj = await redis.client.setCache(key, data);- await redis.client.expire(key, 86400);-- return obj;+ return redis.client.store(key, data, 86400);}-async function deleteWebsite(id) {- return redis.client.deleteCache(`website:${id}`);+async function deleteWebsite(id: any) {+ return redis.client.remove(`website:${id}`);}-async function fetchUser(id): Promise<User> {- return redis.client.getCache(`user:${id}`, () => getUser(id, { includePassword: true }), 86400);+async function fetchUser(id: string): Promise<User> {+ return redis.client.fetch(`user:${id}`, () => getUser(id, { includePassword: true }), 86400);}-async function storeUser(data) {+async function storeUser(data: { id: any }) {const { id } = data;const key = `user:${id}`;- const obj = await redis.client.setCache(key, data);- await redis.client.expire(key, 86400);-- return obj;+ return redis.client.store(key, data, 86400);}-async function deleteUser(id) {- return redis.client.deleteCache(`user:${id}`);+async function deleteUser(id: any) {+ return redis.client.remove(`user:${id}`);}-async function fetchSession(id) {- return redis.client.getCache(`session:${id}`, () => getSession(id), 86400);+async function fetchSession(id: string) {+ return redis.client.fetch(`session:${id}`, () => getSession(id), 86400);}-async function storeSession(data) {+async function storeSession(data: { id: any }) {const { id } = data;const key = `session:${id}`;- const obj = await redis.client.setCache(key, data);- await redis.client.expire(key, 86400);-- return obj;+ return redis.client.store(key, data, 86400);}-async function deleteSession(id) {- return redis.client.deleteCache(`session:${id}`);+async function deleteSession(id: any) {+ return redis.client.remove(`session:${id}`);}async function fetchUserBlock(userId: string) {diff --git a/yarn.lock b/yarn.lockindex 8373fbf0a..38812c614 100644--- a/yarn.lock+++ b/yarn.lock@@ -3200,10 +3200,10 @@chalk "^4.1.2"debug "^4.3.4"-"@umami/redis-client@^0.18.0":- version "0.18.0"- resolved "https://registry.yarnpkg.com/@umami/redis-client/-/redis-client-0.18.0.tgz#6a2315a878f2688dae162d93e88dfc4e097fc48e"- integrity sha512-uDuX5w7ydlOZWrq0h6fADG3XWOhto9fAqrUVu85FUhdijWoGlv5f8adaL8FAah5jD+/Byw2VyGQaZO4VhboEZw==+"@umami/redis-client@^0.20.0":+ version "0.20.0"+ resolved "https://registry.yarnpkg.com/@umami/redis-client/-/redis-client-0.20.0.tgz#93b4598d68983b1ad266a0a527c56533c6248bf2"+ integrity sha512-ACpoO+M/J2eLWEtusjbslhR4le+rPN4h9x7TXjaVJ905icVE0Qgu5y+A7nxXjcYvlgkHk+8HPeVeeaw5P+rxqw==dependencies:debug "^4.3.4"redis "^4.5.1"