mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-09 03:26:38 +08:00
redis null
This commit is contained in:
parent
cc8b1e35c6
commit
c93d001be5
@ -31,6 +31,10 @@ export const incrementSignInCount = async (email: string | undefined, dateKey: s
|
||||
}
|
||||
|
||||
const redis = getRedisClient();
|
||||
if (!redis) {
|
||||
console.error('Redis client is not initialized.');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await redis.hincrby(`signin_count:${email}`, dateKey, 1);
|
||||
@ -46,6 +50,10 @@ export const incrementSessionRefreshCount = async (email: string | undefined, da
|
||||
}
|
||||
|
||||
const redis = getRedisClient();
|
||||
if (!redis) {
|
||||
console.error('Redis client is not initialized.');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await redis.hincrby(`session_refreshes:${email}`, dateKey, 1);
|
||||
@ -66,6 +74,10 @@ export const incrementTokenCounts = async (
|
||||
}
|
||||
|
||||
const redis = getRedisClient();
|
||||
if (!redis) {
|
||||
console.error('Redis client is not initialized.');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await redis.hincrby(`tokens:${email}`, `${dateKey}:completion_tokens`, completionTokens);
|
||||
@ -79,6 +91,10 @@ export const incrementTokenCounts = async (
|
||||
export const getAvailableDateKeys = async (): Promise<string[]> => {
|
||||
|
||||
const redis = getRedisClient();
|
||||
if (!redis) {
|
||||
console.error('Redis client is not initialized.');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const keys = await redis.keys('signin_count:*');
|
||||
@ -92,6 +108,10 @@ export const getAvailableDateKeys = async (): Promise<string[]> => {
|
||||
export const getSignInCountForPeriod = async (dateKey: string): Promise<number> => {
|
||||
|
||||
const redis = getRedisClient();
|
||||
if (!redis) {
|
||||
console.error('Redis client is not initialized.');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const counts = await redis.hgetall(`signin_count:${dateKey}`);
|
||||
@ -117,6 +137,10 @@ export const getSignInCountForPeriod = async (dateKey: string): Promise<number>
|
||||
export const getDetailsByUser = async (dateKey: string): Promise<Record<string, number>> => {
|
||||
|
||||
const redis = getRedisClient();
|
||||
if (!redis) {
|
||||
console.error('Redis client is not initialized.');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const rawCounts = await redis.hgetall(`signin_count:${dateKey}`);
|
||||
|
Loading…
Reference in New Issue
Block a user