-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
add support for all hash field expiration commands #2742
base: v5
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looking good, but:
- I've made some changes, please review them..
- Seems like
HGETF
andHSETF
are missing
change look fine |
wondering why you didn't do an enum like response for HEXPIRETIME? |
I see why, as it returns a negative number on "error" (enum) and any positive number on "success", and can't capture that conception in typescript. |
otherwise changes looks fine, and I messed up initial tests, thanks for fixing. |
We can make an enum for type x = 1 | 2 | number; I think that some users will find the enum useful.. |
so I tried something like that, but it seemed like it ended up being shown as just number (as number is a superset of 1/2) |
It's possible, but a bit more complicated than that and even if we don't use that in the return type, I think that some users will still find the enum useful (something like |
I agree, but I can't seem to get omit to work with NumberReply as NumerReply expects a number subtype, but Omit doesn't seem to return an number that can be used by it, and when I created a type manually without NumberReply, it didn't seem to make a difference in practice, was still just number. but yes, I created the enum to use, just unsure how to expose it to the user. export const HASH_FIELD_EXPIRETIME = { |
key: RedisArgument, | ||
fields: RedisVariadicArgument, | ||
seconds: number, | ||
mode?: 'NX' | 'XX' | 'GT' | 'LT', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we do
interface HExpireOptions {
mode?: 'NX' | 'XX' | 'GT' | 'LT';
}
for "future proofing" (in case there will be more optional arguments)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it doesn't really future proof, it just makes it easier if these options are shared between multiple commands. Unsure it adds that much.
transformArguments(key: RedisArgument, fields: RedisVariadicArgument) { | ||
return pushVariadicArgument(['HTTL', key], fields); | ||
}, | ||
transformReply: undefined as unknown as () => ArrayReply<NumberReply> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the reply is array of
Integer reply: -2 if no such field exists in the provided hash key, or the provided key does not exist.
Integer reply: -1 if the field exists but has no associated expiration set.
Integer reply: the TTL in seconds.
should we create an "enum" (not the TS one) for the -2 and -1 values? IDK if I like having them anymore..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
an enum can have value to refrer to negative values by name. but isn't that what I did before ala
export const HASH_FIELD_EXPIRETIME = {
/** The field does not exist /
FIELD_NOT_EXISTS: -2,
/* The field has no expiration time */
NO_EXPIRATION_TIME: -1,
} as const;
Description
adds the has field expiration commands - for testing purposes, need a docker container that has it in it.
Checklist
npm test
pass with this change (including linting)?