2808 explained code solutions for 75 technologies


lua-redisGet all hash values using hgetall


local redis = (require 'redis').connect('127.0.0.1', 6379)
local values = redis:hgetall('hash_test')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

hash_test

hash name

hgetall

returns all key/values from given hash


Usage example

local redis = (require 'redis').connect('127.0.0.1', 6379)
redis:hset('htst', 'a', '1')
redis:hset('htst', 'b', '2')
local values = redis:hgetall('htst')

for k,v in pairs(values) do
  print(k, v)
end
output
a   1
b   2

link_youtube: https://youtu.be/7VJIYrvFMrE