Skip to content

Commit

Permalink
Cache cleanup fix, redirect root to github repo
Browse files Browse the repository at this point in the history
  • Loading branch information
pgaskin committed Apr 5, 2019
1 parent 59c37d6 commit c065a51
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cache.go
Expand Up @@ -46,7 +46,7 @@ func (c *memoryCache) Clean() {
}

// TODO: this is inefficient
if c.size > c.Limit {
if c.Limit > 0 && c.size > c.Limit {
ids, times := make([]string, len(c.entries)), make([]time.Time, len(c.entries))
var i int
for id, entry := range c.entries {
Expand Down Expand Up @@ -86,7 +86,7 @@ func (c *memoryCache) Put(id string, buf []byte, extra string, exp time.Duration
defer c.mu.Unlock()
c.ensureInit()

if int64(len(buf)) > c.Limit {
if c.Limit > 0 && int64(len(buf)) > c.Limit {
if c.Verbose {
fmt.Printf("memoryCache.Put: cache too full: %s: %s\n", exp, id)
}
Expand Down
1 change: 1 addition & 0 deletions kfwproxy.go
Expand Up @@ -21,6 +21,7 @@ func main() {
h := &memoryCache{Limit: *cacheLimit * 1000000, Verbose: *verbose}
r := httprouter.New()

r.GET("/", handler(http.RedirectHandler("https://github.com/geek1011/kfwproxy", http.StatusTemporaryRedirect)))
r.GET("/stats", handler(http.HandlerFunc(h.handleStats)))

r.GET("/api.kobobooks.com/1.0/UpgradeCheck/Device/:device/:affiliate/:version/:serial", handler(
Expand Down

0 comments on commit c065a51

Please sign in to comment.