Skip to content

Commit 96ef113

Browse files
豆腐花kkHAIKE
豆腐花
authored andcommitted
补充修复
1 parent 83fcdbe commit 96ef113

File tree

2 files changed

+13
-20
lines changed

2 files changed

+13
-20
lines changed

memcache_req.go

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"io"
99
"strconv"
1010
"strings"
11-
"time"
1211
)
1312

1413
// RealtimeMaxDelta is max delta time.
@@ -127,11 +126,11 @@ func ReadRequest(r *bufio.Reader) (req *Request, err error) {
127126
if err != nil {
128127
return nil, NewError("cannot read exptime " + err.Error())
129128
}
130-
if req.Exptime > 0 {
131-
if req.Exptime <= RealtimeMaxDelta {
132-
req.Exptime = time.Now().Unix()/1e9 + req.Exptime
133-
}
134-
}
129+
// if req.Exptime > 0 {
130+
// if req.Exptime <= RealtimeMaxDelta { // <= 30 days
131+
// req.Exptime = time.Now().Unix() + req.Exptime
132+
// }
133+
// }
135134

136135
bytes, err := strconv.Atoi(arr[4])
137136
if err != nil {
@@ -172,7 +171,7 @@ func ReadRequest(r *bufio.Reader) (req *Request, err error) {
172171
}
173172
req := &Request{}
174173
req.Command = arr[0]
175-
req.Key = arr[2]
174+
req.Key = arr[1]
176175

177176
if len(arr) > 2 && arr[2] == "noreply" {
178177
req.Noreply = true
@@ -223,11 +222,11 @@ func ReadRequest(r *bufio.Reader) (req *Request, err error) {
223222
if err != nil {
224223
return nil, NewError("cannot read exptime " + err.Error())
225224
}
226-
if req.Exptime > 0 {
227-
if req.Exptime <= RealtimeMaxDelta {
228-
req.Exptime = time.Now().Unix()/1e9 + req.Exptime
229-
}
230-
}
225+
// if req.Exptime > 0 {
226+
// if req.Exptime <= RealtimeMaxDelta { // <= 30 days
227+
// req.Exptime = time.Now().Unix() + req.Exptime
228+
// }
229+
// }
231230

232231
if len(arr) > 3 && arr[3] == "noreply" {
233232
req.Noreply = true

memcached_test.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,8 @@ func DefaultSet(ctx context.Context, req *Request, res *Response) error {
117117
}
118118

119119
func DefaultDelete(ctx context.Context, req *Request, res *Response) error {
120-
count := 0
121-
for _, key := range req.Keys {
122-
if _, exists := memStore.Load(key); exists {
123-
memStore.Delete(key)
124-
count++
125-
}
126-
}
127-
if count > 0 {
120+
if _, exists := memStore.Load(req.Key); exists {
121+
memStore.Delete(req.Key)
128122
res.Response = RespDeleted
129123
} else {
130124
res.Response = RespNotFound

0 commit comments

Comments
 (0)