-
Notifications
You must be signed in to change notification settings - Fork 31
Open
Description
In the CacheInstance interface, the set method includes a ttl parameter. However, the current naming and lack of JSDoc documentation make it unclear whether the ttl value is interpreted in seconds or milliseconds. This ambiguity can lead to confusion for developers using the library, potentially causing incorrect cache expiration behavior.
Proposed Solutions
1 Rename the ttl parameter to a more descriptive name that explicitly indicates the unit of time.
Suggested options:
- ttlInSeconds / ttlMs
- expiresAfterMs / expiresAfterSecond
- lifespanSeconds / lifespanMs
2 Add JSDoc documentation to clearly specify the unit of time and provide details about the parameter's purpose.
Assuming the ttl is in milliseconds (please confirm the intended unit), the updated interface could look like this:
interface CacheInstance {
/**
* Sets a key-value pair in the cache with a specified expiration time.
* @param key - The cache key.
* @param value - The value to cache.
* @param ttl - The time-to-live for the cache entry, in milliseconds.
*/
set(key: string, value: any, ttl: number): void;
}I might suggest a PR for at least add the JSDoc, please confirm that it's in miliseconds <3
Thank you!
Metadata
Metadata
Assignees
Labels
No labels