-
Notifications
You must be signed in to change notification settings - Fork 3
[WIP] feat: warm cold levels cache #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a43f9d8
487baea
02ef245
82607e8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -91,7 +91,7 @@ func (c *Caching) setXCache(resp *http.Response) { | |
| return | ||
| } | ||
|
|
||
| resp.Header.Set(constants.ProtocolCacheStatusKey, strings.Join([]string{c.cacheStatus.String(), "from", c.opt.Hostname, "(tavern/4.0)"}, " ")) | ||
| resp.Header.Set(constants.ProtocolCacheStatusKey, strings.Join([]string{c.cacheStatus.String(), "from", c.opt.Hostname, c.bucket.StoreType(), "(tavern/4.0)"}, " ")) | ||
|
||
|
|
||
| metric := metrics.FromContext(c.req.Context()) | ||
| metric.CacheStatus = c.cacheStatus.String() | ||
|
|
@@ -188,6 +188,7 @@ func getContents(c *Caching, reqChunks []uint32, from uint32) (io.ReadCloser, in | |
| c.log.Debugf("find available chunk index %d, availableChunks: %v", index, availableChunks) | ||
| fromByte := uint64(reqChunks[from] * uint32(c.md.BlockSize)) | ||
| if index < len(availableChunks) { | ||
|
|
||
| chunkFile, _ := getSliceChunkFile(c, availableChunks[index]) | ||
| if chunkFile != nil { | ||
| if err := checkChunkSize(c, chunkFile, idx); err != nil { | ||
|
|
@@ -310,17 +311,19 @@ func cloneRequest(req *http.Request) *http.Request { | |
| return proxyReq | ||
| } | ||
|
|
||
| func newObjectIDFromRequest(req *http.Request, vd string, includeQuery bool) (*object.ID, error) { | ||
| // option: cache-key include querystring | ||
| // | ||
| // TODO: get cache-key from frontend protocol rule. | ||
| func newObjectIDFromRequest(req *http.Request, vd string, includeQuery bool) *object.ID { | ||
| // get cache-key from frontend protocol rule. | ||
| if cacheKey := req.Header.Get(constants.InternalStoreUrl); cacheKey != "" { | ||
| return object.NewVirtualID(cacheKey, vd) | ||
| } | ||
|
|
||
| // option: cache-key include querystring | ||
| // or later default rule. | ||
| if includeQuery { | ||
| return object.NewVirtualID(req.URL.String(), vd), nil | ||
| return object.NewVirtualID(req.URL.String(), vd) | ||
| } | ||
|
|
||
| return object.NewVirtualID(fmt.Sprintf("%s://%s%s", req.URL.Scheme, req.Host, req.URL.Path), vd), nil | ||
| return object.NewVirtualID(fmt.Sprintf("%s://%s%s", req.URL.Scheme, req.Host, req.URL.Path), vd) | ||
| } | ||
|
|
||
| func closeBody(resp *http.Response) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment on line 100 contains Chinese text "时间窗口内命中 >= N" which translates to "hits within time window >= N". For consistency and to make the codebase more accessible to all contributors, consider using English for comments. The same issue appears on lines 101, 102, 105, 106, and 107.