-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bring all modules / all commands into v5
update unstableResp3Module flag to only commands that have unstable api add ability to tag commands to ignore user type mapping (as transformReply will convert it to a non typed map type) update bloom info commands to work with new non typed map ability fill in search/time-series commands and tag with unstableResp3Modules flag as appropriate
- Loading branch information
Showing
53 changed files
with
1,070 additions
and
568 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,70 @@ | ||
import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types'; | ||
import { RedisArgument, Command, UnwrapReply, NullReply, BlobStringReply, NumberReply, TuplesToMapReply, Resp2Reply } from '@redis/client/dist/lib/RESP/types'; | ||
|
||
export type BfInfoReplyMap = TuplesToMapReply<[ | ||
[BlobStringReply<'Capacity'>, NumberReply], | ||
[BlobStringReply<'Size'>, NumberReply], | ||
[BlobStringReply<'Number of filters'>, NumberReply], | ||
[BlobStringReply<'Number of items inserted'>, NumberReply], | ||
[BlobStringReply<'Expansion rate'>, NullReply | NumberReply] | ||
]>; | ||
|
||
export interface BfInfoReply { | ||
capacity?: NumberReply; | ||
size?: NumberReply; | ||
numberOfFilters?: NumberReply; | ||
numberOfInsertedItems?: NumberReply; | ||
expansionRate?: NullReply | NumberReply; | ||
} | ||
|
||
export default { | ||
FIRST_KEY_INDEX: 1, | ||
IS_READ_ONLY: true, | ||
transformArguments(key: RedisArgument) { | ||
return ['BF.INFO', key]; | ||
}, | ||
// TODO | ||
transformReply: undefined as unknown as () => any | ||
transformReply: { | ||
2: (reply: UnwrapReply<Resp2Reply<BfInfoReplyMap>>): BfInfoReply => { | ||
return { | ||
capacity: reply[1], | ||
size: reply[3], | ||
numberOfFilters: reply[5], | ||
numberOfInsertedItems: reply[7], | ||
expansionRate: reply[9] | ||
} | ||
}, | ||
3: (reply: UnwrapReply<BfInfoReplyMap>) => { | ||
if (reply instanceof Map) { | ||
throw new Error("BF.INFO shouldn't return a map type in resp3 anymore"); | ||
/* | ||
return { | ||
capacity: reply.get("Capacity" as unknown as BlobStringReply<'Capacity'>), | ||
size: reply.get("Size" as unknown as BlobStringReply<"Size">), | ||
numberOfFilters: reply.get("Number of filters" as unknown as BlobStringReply<"Number of filters">), | ||
numberOfInsertedItems: reply.get('Number of items inserted' as unknown as BlobStringReply<'Number of items inserted'>), | ||
expansionRate: reply.get('Expansion rate' as unknown as BlobStringReply<'Expansion rate'>), | ||
} | ||
*/ | ||
} else if (reply instanceof Array) { | ||
throw new Error("BF.INFO shouldn't return a array type in resp3 anymore"); | ||
/* | ||
return { | ||
capacity: reply[1], | ||
size: reply[3], | ||
numberOfFilters: reply[5], | ||
numberOfInsertedItems: reply[7], | ||
expansionRate: reply[9] | ||
} | ||
*/ | ||
} else { | ||
return { | ||
capacity: reply["Capacity"], | ||
size: reply["Size"], | ||
numberOfFilters: reply["Number of filters"], | ||
numberOfInsertedItems: reply["Number of items inserted"], | ||
expansionRate: reply["Expansion rate"] | ||
} | ||
} | ||
}, | ||
}, | ||
ignoreTypeMapping: true | ||
} as const satisfies Command; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,89 @@ | ||
import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types'; | ||
import { RedisArgument, Command, NumberReply, BlobStringReply, TuplesToMapReply, UnwrapReply, Resp2Reply } from '@redis/client/dist/lib/RESP/types'; | ||
|
||
export type CfInfoReplyMap = TuplesToMapReply<[ | ||
[BlobStringReply<'Size'>, NumberReply], | ||
[BlobStringReply<'Number of buckets'>, NumberReply], | ||
[BlobStringReply<'Number of filters'>, NumberReply], | ||
[BlobStringReply<'Number of items inserted'>, NumberReply], | ||
[BlobStringReply<'Number of items deleted'>, NumberReply], | ||
[BlobStringReply<'Bucket size'>, NumberReply], | ||
[BlobStringReply<'Expansion rate'>, NumberReply], | ||
[BlobStringReply<'Max iterations'>, NumberReply] | ||
]>; | ||
|
||
export interface CfInfoReply { | ||
size: NumberReply; | ||
numberOfBuckets: NumberReply; | ||
numberOfFilters: NumberReply; | ||
numberOfInsertedItems: NumberReply; | ||
numberOfDeletedItems: NumberReply; | ||
bucketSize: NumberReply; | ||
expansionRate: NumberReply; | ||
maxIteration: NumberReply; | ||
} | ||
|
||
export default { | ||
FIRST_KEY_INDEX: 1, | ||
IS_READ_ONLY: true, | ||
transformArguments(key: RedisArgument) { | ||
return ['CF.INFO', key]; | ||
}, | ||
// TODO | ||
// export type InfoRawReply = [ | ||
// _: string, | ||
// size: number, | ||
// _: string, | ||
// numberOfBuckets: number, | ||
// _: string, | ||
// numberOfFilters: number, | ||
// _: string, | ||
// numberOfInsertedItems: number, | ||
// _: string, | ||
// numberOfDeletedItems: number, | ||
// _: string, | ||
// bucketSize: number, | ||
// _: string, | ||
// expansionRate: number, | ||
// _: string, | ||
// maxIteration: number | ||
// ]; | ||
|
||
// export interface InfoReply { | ||
// size: number; | ||
// numberOfBuckets: number; | ||
// numberOfFilters: number; | ||
// numberOfInsertedItems: number; | ||
// numberOfDeletedItems: number; | ||
// bucketSize: number; | ||
// expansionRate: number; | ||
// maxIteration: number; | ||
// } | ||
|
||
// export function transformReply(reply: InfoRawReply): InfoReply { | ||
// return { | ||
// size: reply[1], | ||
// numberOfBuckets: reply[3], | ||
// numberOfFilters: reply[5], | ||
// numberOfInsertedItems: reply[7], | ||
// numberOfDeletedItems: reply[9], | ||
// bucketSize: reply[11], | ||
// expansionRate: reply[13], | ||
// maxIteration: reply[15] | ||
// }; | ||
// } | ||
transformReply: undefined as unknown as () => any | ||
|
||
transformReply: { | ||
2: (reply: UnwrapReply<Resp2Reply<CfInfoReplyMap>>): CfInfoReply => { | ||
return { | ||
size: reply[1], | ||
numberOfBuckets: reply[3], | ||
numberOfFilters: reply[5], | ||
numberOfInsertedItems: reply[7], | ||
numberOfDeletedItems: reply[9], | ||
bucketSize: reply[11], | ||
expansionRate: reply[13], | ||
maxIteration: reply[15] | ||
} | ||
}, | ||
3: (reply: UnwrapReply<CfInfoReplyMap>): CfInfoReply => { | ||
if (reply instanceof Map) { | ||
throw new Error("BF.INFO shouldn't return a map type in resp3 anymore"); | ||
/* | ||
return { | ||
size: reply.get("Size" as unknown as BlobStringReply<"Size">)!, | ||
numberOfBuckets: reply.get('Number of buckets' as unknown as BlobStringReply<'Number of buckets'>)!, | ||
numberOfFilters: reply.get('Number of filters' as unknown as BlobStringReply<"Number of filters">)!, | ||
numberOfInsertedItems: reply.get('Number of items inserted' as unknown as BlobStringReply<'Number of items inserted'>)!, | ||
numberOfDeletedItems: reply.get('Number of items deleted' as unknown as BlobStringReply<'Number of items deleted'>)!, | ||
bucketSize: reply.get('Bucket size' as unknown as BlobStringReply<'Bucket size'>)!, | ||
expansionRate: reply.get('Expansion rate' as unknown as BlobStringReply<'Expansion rate'>)!, | ||
maxIteration: reply.get('Max iterations' as unknown as BlobStringReply<'Max iterations'>)! | ||
} | ||
*/ | ||
} else if (reply instanceof Array) { | ||
throw new Error("BF.INFO shouldn't return a array type in resp3 anymore"); | ||
/* | ||
return { | ||
size: reply[1], | ||
numberOfBuckets: reply[3], | ||
numberOfFilters: reply[5], | ||
numberOfInsertedItems: reply[7], | ||
numberOfDeletedItems: reply[9], | ||
bucketSize: reply[11], | ||
expansionRate: reply[13], | ||
maxIteration: reply[15] | ||
} | ||
*/ | ||
} else { | ||
return { | ||
size: reply['Size'], | ||
numberOfBuckets: reply['Number of buckets'], | ||
numberOfFilters: reply['Number of filters'], | ||
numberOfInsertedItems: reply['Number of items inserted'], | ||
numberOfDeletedItems: reply['Number of items deleted'], | ||
bucketSize: reply['Bucket size'], | ||
expansionRate: reply['Expansion rate'], | ||
maxIteration: reply['Max iterations'] | ||
} | ||
} | ||
} | ||
}, | ||
ignoreTypeMapping: true | ||
} as const satisfies Command; |
Oops, something went wrong.