1

I want to save a large JSON to Redis. The size is: 5 MB, approximately.

Is there any way to zip the JSON, then save to Redis. And, I need it as getting the unzipped data from Redis is slow.

16ctt1x
  • 321
  • 6
  • 21
XCode
  • 31
  • 1
  • 4
  • Duplicate of https://stackoverflow.com/questions/2118904/zip-and-unzip-string-with-deflate. Use the `Deflate` algorithm to return you a `byte[]` which contains the compressed data for you to save (in Base64 encoding if you can't store byte arrays directly but only strings). You can then `Inflate` the `byte[]` again to receive your original data.. – Maximilian Gerhardt Jul 26 '16 at 15:34

1 Answers1

2

If you use the C# StackExchange.Redis library, it has the ability to store binary data as one of the overloads (byte[]). Then it's simply a matter of using the .NET compression library to go to and from compressed byte[].

Aside from that you would need to write the data yourself as an encoded string using RESP. See here: http://redis.io/topics/protocol

Joseph Rosson
  • 334
  • 1
  • 8