redisson icon indicating copy to clipboard operation
redisson copied to clipboard

InputStream and OutputStream support

Open jackygurui opened this issue 10 years ago • 4 comments

From Gitter user @cdeszaq:

Wanting to keep memory usage within my app as low as possible. We're getting large collection-like responses from a backend system, processing them "item" at a time, and we want to be able to cache that response in a streamy way

Needs to keep memory low are many concurrent requests, large collections of things processed a streamy way, and we're hitting issues with OOM due to having large strings flying around

It's a CSV response from a back-end webservice, so we process it in a streamy way, but it'll easily get to sizes of 100MB for each response, and we often have to have 30+ of these responses being processed at once. We process it 1 row at a time within our code to keep memory low, but hit OOM when we go to/from our current caching layer because it converts to/from massive strings

jackygurui avatar Oct 17 '16 20:10 jackygurui

The biggest rationale for this is that InputStream and OutputStream are Java's original (and best supported / lowest level) way to process data in a streamy way and keep a minimal memory footprint. Having Redisson support for this low-level, fundamental aspect of Java would give a huge amount of flexibility around dealing with this sort of problem.

cdeszaq avatar Oct 17 '16 21:10 cdeszaq

From Gitter recap:

It’s also worth mention is that each redis string supports 512 Megabytes in length, so some book keeping objects is going to be required.

Book keeping objects should be lightweight and agile.

jackygurui avatar Oct 17 '16 22:10 jackygurui

Here is an overview of suggested RStream object which will be implemented:

public class RStream extends RBucket<byte[]> {

       InputStream input();

       OutputStream output();

}

mrniko avatar Oct 18 '16 09:10 mrniko

Done

mrniko avatar Nov 04 '16 15:11 mrniko