mirror of
https://github.com/kremalicious/umami.git
synced 2025-02-14 21:10:34 +01:00
Updated redis methods.
This commit is contained in:
parent
4ca4be4445
commit
592c181902
@ -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",
|
||||
|
@ -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) {
|
||||
|
@ -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"
|
||||
|
Loading…
x
Reference in New Issue
Block a user