-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Add ledis cache support #16035
Add ledis cache support #16035
Conversation
Codecov Report
@@ Coverage Diff @@
## main #16035 +/- ##
=======================================
Coverage 45.43% 45.43%
=======================================
Files 709 709
Lines 83686 83691 +5
=======================================
+ Hits 38022 38028 +6
- Misses 39564 39565 +1
+ Partials 6100 6098 -2
Continue to review full report at Codecov.
|
What is |
I am slightly concerned that this is adding another different level dB to the system. It would not be difficult to add a leveldb caching provider using our current leveldb by looking at this code nor should it be difficult to switch our leveldb provider over to the rdb that is in here but we shouldn't have two leveldbs. Interestingly in the dependencies for this rdb is a mmap implementation - which (if we were happy to add - I think this is a cgo dependency) could be used in go-git for its commit-graph reader and some other places in gitea. |
It's a pure golang k/v database which have a redis similiar interface but stored all data into disk. It's based on go leveldb. So that's it's name @zeripath The cache interface requires |
I've just understood the reasoning behind this. Is it really the case that the memory cache just grows without limit? That's kinda crazy. Is there any limit on this cache? |
If the cache haven't given a timeout when set, it will always be kept in memory when it's a memory provider. We also have redis implementation, but for a small instance, I think it's too overhead. The memory cache will be cleared when Gitea restarted even if the cache item is not timeout. For a last commit info cache, it's bad. |
Ok this absolutely needs fixing. I just don't understand why anyone would write a cache that's not size limited in some way... Are the redis and ledis caches at least size limited in some way? |
The cache library derived from macaron middlewares and as I know there is no size limit for all these implementations. |
o_O Then this just swaps the problem of memory for one of disk space and is not much better. |
Ok. I think we need to change the memory one to be a wrapper around an lru. If you get a cache hit just check if it's already expired and delete it if so. That's probably the simplest thing to do - as although that means that the cache may contain expired data that data is likely not to be hot anyway and is more likely to get thrown out in an lru cache. There's probably a library out there that has this kind of wrapping already. For the ledis and redis caches - we can't be the first to have to do this surely? There has to be a way of limiting these caches. |
Ok redis has volatile-lru, volatile-ttl and allkeys-lru options. I think therefore Redis is a configuration issue for redis users - as long as our implementation is setting expires correctly. (Likely we should not be recommending allkeys-lru if they're using redis for queues.) We should check that sessions have an expire set on them too. |
Ledis lib looks stale as zeripath pointed out :/ |
The ledis project seems not active anymore. Should we give it up? |
This PR adds a new cache provider
ledis
which have been implemented ingo-chi/cache
but not supported.For those Gitea instances which have lower memory but want to cache last commit information, it's a better case than memory or redis.