Add LRU mem cache implementation (#16226)
The current default memory cache implementation is unbounded in size and number of objects cached. This is hardly ideal. This PR proposes creating a TwoQueue LRU cache as the underlying cache for Gitea. The cache is limited by the number of objects stored in the cache (rather than size) for simplicity. The default number of objects is 50000 - which is perhaps too small as most of our objects cached are going to be much less than 1kB. It may be worth considering using a different LRU implementation that actively limits sizes or avoids GC - however, this is just a beginning implementation. Signed-off-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
parent
07284792d4
commit
2f725cbc9e
5 changed files with 219 additions and 6 deletions
|
@ -1471,7 +1471,7 @@ PATH =
|
|||
;; if the cache enabled
|
||||
;ENABLED = true
|
||||
;;
|
||||
;; Either "memory", "redis", or "memcache", default is "memory"
|
||||
;; Either "memory", "redis", "memcache", or "twoqueue". default is "memory"
|
||||
;ADAPTER = memory
|
||||
;;
|
||||
;; For "memory" only, GC interval in seconds, default is 60
|
||||
|
@ -1480,6 +1480,7 @@ PATH =
|
|||
;; For "redis" and "memcache", connection host address
|
||||
;; redis: network=tcp,addr=:6379,password=macaron,db=0,pool_size=100,idle_timeout=180
|
||||
;; memcache: `127.0.0.1:11211`
|
||||
;; twoqueue: `{"size":50000,"recent_ratio":0.25,"ghost_ratio":0.5}` or `50000`
|
||||
;HOST =
|
||||
;;
|
||||
;; Time to keep items in cache if not used, default is 16 hours.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue