Search code examples
redisspring-data-redis

Redis performance: hIncrByFloat function or custom Lua script ?


let's say I have hash data stored in redis:

{"fee":0.11,"name":"scott"}

now I want to add some value to the field 'fee', should I use the hIncrByFloat command or , write a Lua script to implement that? please advice from the performance view, thanks!


Solution

  • Use HINCRBYFLOAT.

    Core commands are more performant than Lua scripts in (probably) every scenario. Use Lua to compose flows that consist of core commands and server-side logic, but not to replace a single core command.

    You can, and should, test performance yourself - redis-benchmark can be used for that.