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

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

.htaccess - ERR_TOO_MANY_REDIRECTS htaccess -