mirror of
https://github.com/kremalicious/umami.git
synced 2025-02-14 21:10:34 +01:00
Update redis client.
This commit is contained in:
parent
a106098129
commit
140cac046b
@ -67,7 +67,7 @@
|
|||||||
"@react-spring/web": "^9.7.3",
|
"@react-spring/web": "^9.7.3",
|
||||||
"@tanstack/react-query": "^4.33.0",
|
"@tanstack/react-query": "^4.33.0",
|
||||||
"@umami/prisma-client": "^0.3.0",
|
"@umami/prisma-client": "^0.3.0",
|
||||||
"@umami/redis-client": "^0.15.0",
|
"@umami/redis-client": "^0.16.0",
|
||||||
"chalk": "^4.1.1",
|
"chalk": "^4.1.1",
|
||||||
"chart.js": "^4.2.1",
|
"chart.js": "^4.2.1",
|
||||||
"chartjs-adapter-date-fns": "^3.0.0",
|
"chartjs-adapter-date-fns": "^3.0.0",
|
||||||
@ -96,6 +96,7 @@
|
|||||||
"next-basics": "^0.36.0",
|
"next-basics": "^0.36.0",
|
||||||
"node-fetch": "^3.2.8",
|
"node-fetch": "^3.2.8",
|
||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
|
"prisma": "5.3.1",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-basics": "^0.105.0",
|
"react-basics": "^0.105.0",
|
||||||
"react-beautiful-dnd": "^13.1.0",
|
"react-beautiful-dnd": "^13.1.0",
|
||||||
@ -146,7 +147,6 @@
|
|||||||
"postcss-preset-env": "7.8.3",
|
"postcss-preset-env": "7.8.3",
|
||||||
"postcss-rtlcss": "^4.0.1",
|
"postcss-rtlcss": "^4.0.1",
|
||||||
"prettier": "^2.6.2",
|
"prettier": "^2.6.2",
|
||||||
"prisma": "5.3.1",
|
|
||||||
"prompts": "2.4.2",
|
"prompts": "2.4.2",
|
||||||
"rollup": "^3.28.0",
|
"rollup": "^3.28.0",
|
||||||
"rollup-plugin-copy": "^3.4.0",
|
"rollup-plugin-copy": "^3.4.0",
|
||||||
|
@ -3,57 +3,57 @@ import redis from '@umami/redis-client';
|
|||||||
import { getSession, getUserById, getWebsiteById } from '../queries';
|
import { getSession, getUserById, getWebsiteById } from '../queries';
|
||||||
|
|
||||||
async function fetchWebsite(id): Promise<Website> {
|
async function fetchWebsite(id): Promise<Website> {
|
||||||
return redis.fetchObject(`website:${id}`, () => getWebsiteById(id), 86400);
|
return redis.getCache(`website:${id}`, () => getWebsiteById(id), 86400);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function storeWebsite(data) {
|
async function storeWebsite(data) {
|
||||||
const { id } = data;
|
const { id } = data;
|
||||||
const key = `website:${id}`;
|
const key = `website:${id}`;
|
||||||
|
|
||||||
const obj = await redis.storeObject(key, data);
|
const obj = await redis.setCache(key, data);
|
||||||
await redis.expire(key, 86400);
|
await redis.expire(key, 86400);
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deleteWebsite(id) {
|
async function deleteWebsite(id) {
|
||||||
return redis.deleteObject(`website:${id}`);
|
return redis.deleteCache(`website:${id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchUser(id): Promise<User> {
|
async function fetchUser(id): Promise<User> {
|
||||||
return redis.fetchObject(`user:${id}`, () => getUserById(id, { includePassword: true }), 86400);
|
return redis.getCache(`user:${id}`, () => getUserById(id, { includePassword: true }), 86400);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function storeUser(data) {
|
async function storeUser(data) {
|
||||||
const { id } = data;
|
const { id } = data;
|
||||||
const key = `user:${id}`;
|
const key = `user:${id}`;
|
||||||
|
|
||||||
const obj = await redis.storeObject(key, data);
|
const obj = await redis.setCache(key, data);
|
||||||
await redis.expire(key, 86400);
|
await redis.expire(key, 86400);
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deleteUser(id) {
|
async function deleteUser(id) {
|
||||||
return redis.deleteObject(`user:${id}`);
|
return redis.deleteCache(`user:${id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchSession(id) {
|
async function fetchSession(id) {
|
||||||
return redis.fetchObject(`session:${id}`, () => getSession(id), 86400);
|
return redis.getCache(`session:${id}`, () => getSession(id), 86400);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function storeSession(data) {
|
async function storeSession(data) {
|
||||||
const { id } = data;
|
const { id } = data;
|
||||||
const key = `session:${id}`;
|
const key = `session:${id}`;
|
||||||
|
|
||||||
const obj = await redis.storeObject(key, data);
|
const obj = await redis.setCache(key, data);
|
||||||
await redis.expire(key, 86400);
|
await redis.expire(key, 86400);
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deleteSession(id) {
|
async function deleteSession(id) {
|
||||||
return redis.deleteObject(`session:${id}`);
|
return redis.deleteCache(`session:${id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchUserBlock(userId: string) {
|
async function fetchUserBlock(userId: string) {
|
||||||
|
@ -2593,10 +2593,10 @@
|
|||||||
chalk "^4.1.2"
|
chalk "^4.1.2"
|
||||||
debug "^4.3.4"
|
debug "^4.3.4"
|
||||||
|
|
||||||
"@umami/redis-client@^0.15.0":
|
"@umami/redis-client@^0.16.0":
|
||||||
version "0.15.0"
|
version "0.16.0"
|
||||||
resolved "https://registry.yarnpkg.com/@umami/redis-client/-/redis-client-0.15.0.tgz#55e9c4ede28fdd3b6a169378d391a5d2cc039e51"
|
resolved "https://registry.yarnpkg.com/@umami/redis-client/-/redis-client-0.16.0.tgz#0050d1f93338d88691c983f3c0cd4a62da20212b"
|
||||||
integrity sha512-+Ei6i4qx9Md4o92Mlzvh9rTgkfllgmSwFu1687DEqFnNrHd+KNVxgNNDiyyCwzfC0t/DAaq7PoOFw4NjJYo9wQ==
|
integrity sha512-fE08lkMvhXbkXSdSRpG0R/9a3xIiTvwD6f+hKERFZrpfvJJlH3Uf4Jod8Ahg/+TmD03ihSQPooUT3T9Ig3dfaQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
debug "^4.3.4"
|
debug "^4.3.4"
|
||||||
redis "^4.5.1"
|
redis "^4.5.1"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user