实现内存缓存

This commit is contained in:
刘祥超
2020-10-05 19:15:35 +08:00
parent d7493c4188
commit 78a2480836
14 changed files with 504 additions and 17 deletions

View File

@@ -64,17 +64,13 @@ func (this *HTTPRequest) doCacheRead() (shouldStop bool) {
return
}
buf := bytePool32k.Get()
defer func() {
bytePool32k.Put(buf)
}()
isBroken := false
headerBuf := []byte{}
statusCode := http.StatusOK
statusFound := false
headerFound := false
buf := bytePool32k.Get()
err := storage.Read(key, buf, func(data []byte, valueSize int64, expiredAt int64, isEOF bool) {
if isBroken {
return
@@ -134,6 +130,8 @@ func (this *HTTPRequest) doCacheRead() (shouldStop bool) {
}
})
bytePool32k.Put(buf)
if err != nil {
if err == caches.ErrNotFound {
// cache相关变量