@JK I don't have much experience working with redis and believe given example is not the best, however I did not find any valuable information in google. So I can change the question to something like:
how to compress data before put into redis.