Godis (like Go + Redis) - implementation of simple Redis-like cache for Go language training. This is the server side of Godis.
- Golang 1.11.2 or higher
- Docker (for running in container)
go clean && go test ./... -coverprofile coverage.out && go build
./godis_server
- -m, -mode -- storage mode of the server: "memory" or "disk" (default "memory")
- -p, -port -- port on which the server runs (default "9090")
Example: ./godis_server -p=8080 -m=disk
docker build -t godis_server .
docker run --rm -p 9090:9090 godis_server
For access the server via HTTP use any HTTP client, There is the list of avalaible resources and methods:
GET
http://localhost:9090/storage?key=key_value
Headers: 'Content-Type:application/json'
URL Params: key (string, required)
Success Response: Code - 200 Ok, Content - {"key":"test","value":"test value"}
Error Response: Code - 404 Not Fount
GET
http://localhost:9090/storage
Headers: 'Content-Type:application/json'
Success Response: Code - 200 Ok, Content - [{"key":"","value":""},{"key":"","value":""},{"key":"test","value":"test value"},{"key":"test2","value":"test value 2"}]
POST
http://localhost:9090/storage
Headers: 'Content-Type:application/json'
Body: '{"key":"test","value":"test value"}'
Success Response: Code - 200 Ok, Content - {"key":"test","value":"test value"}
Error Response: Code - 400 Bad Request, Content - 'Pass the data in next format: {"key":"","value":""}'
DELETE
http://localhost:9090/storage?key=key_value
Headers: 'Content-Type:application/json'
URL Params: key (string, required)
Success Response: Code - 200 Ok
GET
http://localhost:9090/storage/keys?match=value*
Headers: 'Content-Type:application/json'
URL Params: match (string, required, should contain '*')
Success Response: Code - 200 Ok, Content - ["test1","test2","test3"]