Skip to content

Latest commit

 

History

History
24 lines (19 loc) · 692 Bytes

usage-of-lua-scripts-in-redis.md

File metadata and controls

24 lines (19 loc) · 692 Bytes

Usage of LUA scripts in Redis

redis-cli EVAL "return redis.call('get', KEYS[1]) + redis.call('get', KEYS[2]);" 2 key1 key2
  • redis-cli - executes Redis command in bash
  • EVAL - evaluates specified LUA code
  • redis.call - call Redis method
  • 'get' - gets value by Redis key
  • KEYS[1] - refers to first argument passed to EVAL command (key1)
  • KEYS[2] - refers to second argument passed to EVAL command (key2)
  • 2 key1 key2 - number of arguments we'll pass to the command and the arguments themselves

group: eval

Example:

redis-cli EVAL "return redis.call('get', KEYS[1]) + redis.call('get', KEYS[2]);" 2 key1 key2
(integer) 138