Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small refactorings between core and handler #63

Open
SammyWhamy opened this issue Mar 5, 2025 · 0 comments
Open

Small refactorings between core and handler #63

SammyWhamy opened this issue Mar 5, 2025 · 0 comments
Labels
refactoring Something that requires refactoring

Comments

@SammyWhamy
Copy link
Collaborator

SammyWhamy commented Mar 5, 2025

Currently core contains some functions that should not be there:

src/redis.ts - checkRedis

This function should be refactored into something like

type cooldownCheckResult = { canUse: true } | { canUse: false, canUseAt: number };

async function checkCommandCooldown(key: string, cooldown: number, userId: string): Promise<cooldownCheckResult> {
    // If key doesnt exist, set the key+ttl, return { canUse: true }
    // If the key does exist, return { canUse: false,  canUseAt: ... }
}

This function should also be moved to handler, as it is only used for commands.

src/redis.ts - setExpireCommand

This function can probably removed, and we can simply set the TTL, or override it.
If it is necessary to not reset the ttl, we can change this to setexNoReset or something similar, and the logging can be removed.
This can be kept in core without the logging (or changed logging to be more generic).

src/redis.ts - handleExpiration

This function should be named instead like handlerComponentExpiry, and should be moved to handler, as it will be only used there.

@SammyWhamy SammyWhamy added the refactoring Something that requires refactoring label Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Something that requires refactoring
Projects
None yet
Development

No branches or pull requests

1 participant