Skip to main content

Redis testing

Redis cli is great, why use HTTP DSL?

  • It's hard to input JSON with CLI

  • Not good to input Lua Script with eval

  • Redis set with JSON. method is RSET, not SET

RSET admin
Content-Type: application/json

{
"id": 1,
"name": "Admin"
}
  • Redis HMSET to set multi fields from JSON once
### Redis hmset
HMSET user.1
Host: localhost:6379
Content-Type: application/json

{ "id": 1, "name": "jackie"}
  • Redis JSON.SET to set JSON value
### Redis JSON.SET
#@name redis-jsonset
JSONSET user.1/$
Host: localhost:16379
Content-Type: application/json

{
"id": 1,
"name": "jackie",
"age": 42
}
  • Redis JSON.GET to get JSON value
### Redis JSON.GET whole object
#@name redis-jsonget
JSONGET user.1
Host: localhost:16379

or

### redis JSON.GET with $path
#@name redis-jsonget
JSONGET user.1/$path
Host: localhost:16379
  • Redis EVAL script
### redis eval script
EVAL 1 name Jackie
Host: localhost:6379
Content-Type: text/x-lua

local welcome="Hello "
return welcome .. ARGV[1]
### Redis 7 fuctions
//@name redis-mylib
LOAD mylib
Host: localhost:16379
Content-Type: text/x-lua

#!lua name=mylib
redis.register_function(
'knockknock',
function()
return 'Who\'s there?'
end
)

Attention: