3 ms·
Very good points. Actually that's something i started doing too with Node.Js, an HTTP interface to Redis for my personal use. At first i did go with a RESTful
by Mikushi 16y ago
Very good points.
Actually that's something i started doing too with Node.Js, an HTTP interface to Redis for my personal use.
At first i did go with a RESTful approach, but you quickly hit the limit of commands available versus the numbers of commands in Redis.
The choice i did was the following:
Read command are accessed through GET this way:
GET http://localhost:8124/get/mykey http://localhost:8124/get/mykey
200 {"mykey" : "mydata"}
GET http://localhost:8124/hgetall/mykey http://localhost:8124/hgetall/mykey
200 {"hashKey": {"field1": "value1",
"field2": "value2"}}
Write commands are run through PUT or POST :
POST http://localhost:8124/set/key/value http://localhost:8124/set/key/value
201 {"response": 1}
PUT http://localhost:8124/lpush/myList/1 http://localhost:8124/lpush/myList/1
201 {"response": 1}
Delete commands through DELETE.
DELETE http://localhost:8124/del/mykey http://localhost:8124/del/mykey
200 {"response": 1}
DELETE http://localhost:8124/hdel/myHash/field http://localhost:8124/hdel/myHash/field
I'm pretty happy with the result, there are some commands i'm not sure where to put though(lpop, rpop, multi, ...)