diff options
author | zeripath <art27@cantab.net> | 2021-07-10 22:54:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-10 23:54:15 +0200 |
commit | 2f725cbc9e836e1d11b8645ee11ed2c82da8c0b7 (patch) | |
tree | 4528863d2c546dc3126970bff029334694d80e80 /custom | |
parent | 07284792d40c556ec4c9e1c92379a922e746e12b (diff) | |
download | gitea-2f725cbc9e836e1d11b8645ee11ed2c82da8c0b7.tar.gz gitea-2f725cbc9e836e1d11b8645ee11ed2c82da8c0b7.zip |
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>
Diffstat (limited to 'custom')
-rw-r--r-- | custom/conf/app.example.ini | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index 22244545f5..251ec7a80e 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -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. |