Beispiel #1
0
func (srv *Server) get(c *gin.Context) {
	key := c.Param("key")
	if res, err := srv.keystorage.Get(key); err == nil {
		obj := model.NewOvoKVResponse(res)
		result := model.NewOvoResponse("done", "0", obj)
		c.JSON(http.StatusOK, result)
	} else {
		c.JSON(http.StatusNotFound, model.NewOvoResponse("error", "101", nil))
	}
}
Beispiel #2
0
func (srv *Server) getAndRemove(c *gin.Context) {
	key := c.Param("key")
	if res, err := srv.keystorage.GetAndRemove(key); err == nil {
		obj := model.NewOvoKVResponse(res)
		srv.outcmdproc.Enqueu(&command.Command{OpCode: "delete", Obj: &storage.MetaDataUpdObj{Key: key}})
		result := model.NewOvoResponse("done", "0", obj)
		c.JSON(http.StatusOK, result)
	} else {
		c.JSON(http.StatusNotFound, model.NewOvoResponse("error", "101", nil))
	}
}