9951 explained code solutions for 126 technologies


lua-redisSet hash value using hset


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

hset

sets key value of specified hash

hash_test

hash name

'a'

key name

'1'

key value


Usage example

local redis = (require 'redis').connect('127.0.0.1', 6379)

redis:hset('htst', 'a', '1')
redis:hset('htst', 'b', '2')

print(redis:hget('htst', 'b'))
print(redis:hget('htst', 'a'))
output
2
1