feat add set command

This commit is contained in:
Xiang Li
2013-10-14 22:44:17 -07:00
parent 2aeb25e80c
commit 53a9bd0618
5 changed files with 42 additions and 8 deletions

View File

@@ -254,11 +254,10 @@ func (s *Server) SpeedTestHandler(w http.ResponseWriter, req *http.Request) erro
for i := 0; i < count; i++ {
go func() {
for j := 0; j < 10; j++ {
c := &store.CreateCommand{
c := &store.SetCommand{
Key: "foo",
Value: "bar",
ExpireTime: time.Unix(0, 0),
Force: true,
}
s.peerServer.RaftServer().Do(c)
}

View File

@@ -39,11 +39,10 @@ func SetKeyHandler(w http.ResponseWriter, req *http.Request, s Server) error {
}
} else {
c = &store.CreateCommand{
c = &store.SetCommand{
Key: key,
Value: value,
ExpireTime: expireTime,
Force: true,
}
}

View File

@@ -35,11 +35,10 @@ func PutHandler(w http.ResponseWriter, req *http.Request, s Server) error {
// Set command: create a new node or replace the old one.
if !valueOk && !indexOk && !existOk {
c = &store.CreateCommand{
c = &store.SetCommand{
Key: key,
Value: value,
ExpireTime: expireTime,
Force: true,
}
return s.Dispatch(c, w, req)
}