重构:将 "lobster" 重命名为 "claw" 并添加国际化支持 (i18n)
This commit is contained in:
@@ -24,33 +24,33 @@ if (process.env.NODE_ENV !== "production") {
|
||||
}
|
||||
|
||||
const CHANNEL_REALTIME = "channel:realtime";
|
||||
const ACTIVE_LOBSTERS_KEY = "active:lobsters";
|
||||
const ACTIVE_CLAWS_KEY = "active:claws";
|
||||
const STATS_GLOBAL_KEY = "stats:global";
|
||||
const STATS_REGION_KEY = "stats:region";
|
||||
const HEATMAP_CACHE_KEY = "cache:heatmap";
|
||||
const HOURLY_ACTIVITY_KEY = "stats:hourly";
|
||||
|
||||
export async function setLobsterOnline(
|
||||
lobsterId: string,
|
||||
export async function setClawOnline(
|
||||
clawId: string,
|
||||
ip: string
|
||||
): Promise<void> {
|
||||
await redis.set(`lobster:online:${lobsterId}`, ip, "EX", 300);
|
||||
await redis.set(`claw:online:${clawId}`, ip, "EX", 300);
|
||||
}
|
||||
|
||||
export async function isLobsterOnline(lobsterId: string): Promise<boolean> {
|
||||
const result = await redis.exists(`lobster:online:${lobsterId}`);
|
||||
export async function isClawOnline(clawId: string): Promise<boolean> {
|
||||
const result = await redis.exists(`claw:online:${clawId}`);
|
||||
return result === 1;
|
||||
}
|
||||
|
||||
export async function updateActiveLobsters(lobsterId: string): Promise<void> {
|
||||
export async function updateActiveClaws(clawId: string): Promise<void> {
|
||||
const now = Date.now();
|
||||
await redis.zadd(ACTIVE_LOBSTERS_KEY, now, lobsterId);
|
||||
await redis.zadd(ACTIVE_CLAWS_KEY, now, clawId);
|
||||
}
|
||||
|
||||
export async function getActiveLobsterIds(
|
||||
export async function getActiveClawIds(
|
||||
limit: number = 100
|
||||
): Promise<string[]> {
|
||||
return redis.zrevrange(ACTIVE_LOBSTERS_KEY, 0, limit - 1);
|
||||
return redis.zrevrange(ACTIVE_CLAWS_KEY, 0, limit - 1);
|
||||
}
|
||||
|
||||
export async function incrementRegionCount(region: string): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user