0

I'm using Redisson's RMapCache structure because it supports entries eviction by time to live and by setting maximum size of map. While everything works without problems in Java, I've found out that NodeJS app that uses same Redis instance couldn't fetch values from the same underlying HSET structure.

The issue is that Redisson prepends 2 bytes to each value in HSET when RMapCache is used: enter image description here

After spending some time digging in Redisson source code, I've found Lua script used in insertion procedure, which has following lines:

  local val = struct.pack('dLc0', tonumber(ARGV[4]), string.len(ARGV[6]), ARGV[6]);
  redis.call('hset', KEYS[1], ARGV[5], val);

ARGV[6] is value itself, so other two bytes are:

  • max idle time in milliseconds (can be passed to put method)
  • length of value

This effectively makes Redis HSET unusable from other languages or Java clients other then Redisson.

Has somebody encountered same problem and know how to deal with it?

Volodymyr Masliy
  • 413
  • 4
  • 14

1 Answers1

1

RMapCache is entirely a Redisson creation which supports both bounded and unbounded capacity with individual entry eviction by time to live. No other language and clients support these features since they are not supported by Redis.

Redisson packs meta information related to the individual elements along side each value, however that's not the only trick it has to pull to make RMapCache work as intended.

Other clients may be able to read the value by unpacking the data and ignore the meta data, but changing the value without going through Redisson may cause unexpected behaviours on the Redisson client side.

Redisson_RuiGu
  • 1,012
  • 10
  • 13