9951 explained code solutions for 126 technologies


lua-redisHow to delete key


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

del

deletes specified key

key

key name to delete


Usage example

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

redis:set('t_1', 1)
print(redis:get('t_1'))

redis:del('t_1')
print(redis:get('t_1'))
output
1
nil