We are experimenting some performance issue in our Redisson architecture due to the codec encode and decode phases.
Changing codec works a little but is not enought, so we are in mind to avoid completely that phase if it's already been done before, storing the encoded/decoded value in a map in our custom coded.
For example:
private final Map<Object, ByteBuf> encodedKeys = new FixedSizeMap<Object, ByteBuf>(1000); @Override public ByteBuf encode(Object in) throws IOException { ByteBuf key = encodedKeys.get(in); if (in != null) { return key; } ByteBuf out = ByteBufAllocator.DEFAULT.buffer(); ByteBufOutputStream os = new ByteBufOutputStream(out); FSTObjectOutput oos = config.getObjectOutput(os); try { oos.writeObject(in); oos.flush(); key = os.buffer(); encodedKeys.put(in, key); return key; } catch (IOException e) { out.release(); throw e; } catch (Exception e) { out.release(); throw new IOException(e); } finally { if (!useCache) { oos.resetForReUse(emptyArray); } } }};
It this a good practice?
There is already any developed coded that does something like this?