You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please provide source code and commit sha if you found a bug.
Review existing issues and provide feedback or react to them.
Description
I read the source code and did not find the existence of cache. I wonder why there is no cache. Is it because the Web framework does not need cache? Similar to CPU L1 cache, memory TLB. Highly hit interface access cache is fast, no need to re-enter the dictionary tree traversal.
Therefore, I have two ideas, one is to manually increase the cache, the other is to count the number of interfaces, given the interval to automatically update the cache.
The code below is a demo of the first idea, and I'll fill it in if caching works. Hope to get your reply, thank you
How to reproduce
// gin.go
type Engine struct {
...
cachegin bool
cachetable map[string]bool
...
}
func (engine *Engine)SetCache(rpath string) {
if engine.cachegin {
if _, ok := engine.cachetable[rpath]; !ok {
engine.cachetable[rpath] = true
}else{
panic("The cache already exists")
}
}
}
func (engine *Engine) ServeHTTP(w http.ResponseWriter, req *http.Request) {
c := engine.pool.Get().(*Context)
...
if rPath := c.Request.URL.Path; _, ok := engine.cachetable[rPath]; ok {
Do(c)
}else{
engine.handleHTTPRequest(c)
}
engine.pool.Put(c)
}
Expectations
$ curl http://localhost:8201/hello/world
Hello world
Description
I read the source code and did not find the existence of cache. I wonder why there is no cache. Is it because the Web framework does not need cache? Similar to CPU L1 cache, memory TLB. Highly hit interface access cache is fast, no need to re-enter the dictionary tree traversal.
Therefore, I have two ideas, one is to manually increase the cache, the other is to count the number of interfaces, given the interval to automatically update the cache.
The code below is a demo of the first idea, and I'll fill it in if caching works.
Hope to get your reply, thank you
How to reproduce
Expectations
Actual result
Environment
The text was updated successfully, but these errors were encountered: