2808 explained code solutions for 75 technologies


lua-redisGet multiple keys values


local redis = (require 'redis').connect('127.0.0.1', 6379)
local keys = redis:mget({'ma', 'mb'})ctrl + c
require 'redis'

load Redis module for Lua

connect

connect to Redis server

'127.0.0.1', 6379

Redis host and port to connect to

mget

returns multiple keys values

{'ma', 'mb'}

list of key names to get values for

keys

will contain final values list


Usage example

local redis = (require 'redis').connect('127.0.0.1', 6379)
redis:set('ma', '1')
redis:set('mb', '2')

local keys = redis:mget({'ma', 'mb'})
print( table.concat(keys, ', ') )
output
1, 2

link_youtube: https://youtu.be/l12gA2u7yzQ