java - Redis key User Defined object vs String -
i want store , prefix uuid in redis key.but should occupy less memory. better way . below different ways :
1) new object(prefix,uuid)
2) concat(prefix+uuid).
3) convert object protobuff , storing keyr
it depends:
- if prefix+uuid length small, less 30 chars. use concat.
- otherwise longer key lengths go protobuf gzip (if needed), like:
bytearrayoutputstream baos = new bytearrayoutputstream(); gzipoutputstream gzipout = new gzipoutputstream(baos); objectoutputstream objectout = new objectoutputstream(gzipout); // serialise object. objectout.writeobject(prefix+uuid); gzipout.flush(); gzipout.close(); // save byte[] key baos.tobytearray();
Comments
Post a Comment