Reputation: 172
I am using Chronicle Bytes version 1.7.22. I would like to use Bytes for off-heap caching and persistence of large media (e.g. images, videos). Currently I am creating the Bytes as follows:
Bytes.elasticByteBuffer();
OR (for persistence)
MappedBytes.mappedBytes(file, 64);
I have used Bytes.outputStream() to write the media content and used Bytes.inputStream() to read the media content. However, I can only read the InputStream once. It does not seem to support reset. How can I read the media content multiple times and concurrently without allocation of extra memory?
Upvotes: 0
Views: 203
Reputation: 533492
I would suggest you upgrade to the latest 1.9.x version though thus wont fix you problem as such it will fix many bugs.
Bytes is intended to be single threaded however with care the underlying bytes can be shared. You need to create a BytesStore whuch has the shared data and wrap thus with a Bytes eg NativeBytes so you can have a thread local pointer to that data.
If you need to share how long the data is you must store that in the underlying bytes using a thread safe operation.
Upvotes: 0