9951 explained code solutions for 126 technologies


lua-redisDecrement key value


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

:set

sets specified key value

:decr

Decrements specified key

'key'

key name to decrement


Usage example

local redis = (require 'redis').connect('127.0.0.1', 6379)
redis:set('key', 11)
redis:decr('key')
print( redis:get('key') )
output
10