improve(db): do not use keys in redis
This commit is contained in:
@@ -246,12 +246,8 @@ return "OK"
|
||||
}
|
||||
|
||||
if (event.profile_id) {
|
||||
multi.set(
|
||||
`live:event:${event.project_id}:${event.profile_id}`,
|
||||
'',
|
||||
'EX',
|
||||
60 * 5,
|
||||
);
|
||||
multi.sadd(`live:visitors:${event.project_id}`, event.profile_id);
|
||||
multi.expire(`live:visitors:${event.project_id}`, 60 * 5); // 5 minutes
|
||||
}
|
||||
|
||||
if (!_multi) {
|
||||
|
||||
@@ -235,8 +235,7 @@ export function transformMinimalEvent(
|
||||
}
|
||||
|
||||
export async function getLiveVisitors(projectId: string) {
|
||||
const keys = await getRedisCache().keys(`live:event:${projectId}:*`);
|
||||
return keys.length;
|
||||
return getRedisCache().scard(`live:visitors:${projectId}`);
|
||||
}
|
||||
|
||||
export async function getEvents(
|
||||
|
||||
Reference in New Issue
Block a user