6.2. 二进制流(Binary Stream)

Redisson的分布式RBinaryStream Java对象同时提供了InputStream接口和OutputStream接口的实现。流的最大容量受Redis主节点的内存大小限制。

  1. RBinaryStream stream = redisson.getBinaryStream("anyStream");
  2. byte[] content = ...
  3. stream.set(content);
  4. InputStream is = stream.getInputStream();
  5. byte[] readBuffer = new byte[512];
  6. is.read(readBuffer);
  7. OutputStream os = stream.getOuputStream();
  8. byte[] contentToWrite = ...
  9. os.write(contentToWrite);