-
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
fix #1970 - add support for RESTORE
#2535
fix #1970 - add support for RESTORE
#2535
Conversation
885888a
to
ccddaba
Compare
@leibale, should this pair (DUMP & RESTORE) get a specific section in the README, or is the current text enough? |
@Moshe-RS These commands are for "advanced users/use cases", most users will never use them. I don't think we need a section in the readme, but an example in the examples folder will be awesome :) |
ccddaba
to
dd806d4
Compare
It would be great if these functions supported streams so that they could be used with large keys. |
@dtikhonov Currently redis (the server) does not RESP3 streaming, which means to be able to stream you'll have to know the size of the string/buffer ahead of time, which makes it not so useful. Once Redis will implement "streamed strings", we'll be able to support that from the client side as well. @Moshe-RS |
@dtikhonov I thought you want to stream values into redis, not the other way around... I really like this idea, and it could fit nicely with the new WDUT? |
I was thinking that both DUMP and RESTORE could benefit from ability to stream that. The PR was just to show one part of it. (It was simple to write because I was just looking at that part of the code recently.)
We only have to deal with it if we want to use streams in type maps. Is it useful to type all strings as streams in an instance of a Redis client? The API I envision would go something like this: redis.dumpAsStream(key).pipe(outputSteam);
redis.restore(key, 0, inputStream);
/* Anything can be a stream, the client code is smart enough to do this as well: */
redis.hset("foo", "bar", inputStream); |
Streaming to Redis is problematic at the moment because Redis expects an array of "blob strings" as input, each blob string is encoded as Streaming from Redis is something we can do, but I think that string is the only "streamable" data type, how would you stream a map? Regarding "Is it useful to type all strings as streams in an instance of a Redis client?" you don't have to do it for the whole client, you'll be able to do: const client = createClient();
const streamClient = client.withTypeMapping({
[RESP_TYPES.BLOB_STRING]: ReadableStream
});
await client.get('key'); // Promise<string>
await streamClient.get('key'); // Promise<ReadableStream> Hope this is clearer... |
RESTORE
…#1970-Add-support-for-redis-command-RESTORE
Codecov ReportPatch coverage:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #2535 +/- ##
==========================================
+ Coverage 95.71% 95.77% +0.05%
==========================================
Files 458 459 +1
Lines 4531 4544 +13
Branches 506 510 +4
==========================================
+ Hits 4337 4352 +15
+ Misses 127 126 -1
+ Partials 67 66 -1
☔ View full report in Codecov by Sentry. |
@Moshe-RS |
Description
Currently, the DUMP command exists in the client, but there is no way to update the server with that dumped values.
The current pull request adds the RESTORE functionality and allows this.
It follows issue #1970 request.
Checklist
npm test
pass with this change (including linting)?