Skip to content
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

[req]: Use database caching instead of RAM #15007

Open
1 task done
hyoretsu opened this issue Jan 21, 2024 · 5 comments
Open
1 task done

[req]: Use database caching instead of RAM #15007

hyoretsu opened this issue Jan 21, 2024 · 5 comments
Labels
Core Enhancement Needs C# PR Welcome! We would welcome a volunteer to prepare a PR to solve this problem!

Comments

@hyoretsu
Copy link

Is there already a request for your feature?

  • I have checked older issues, open and closed

Is your feature request related to a problem? Please describe.

There's this streaming app called Stremio, and I recently found an add-on called stremio-jackett. It basically queries a Jackett server and returns the results to the app. It takes quite a while to do the initial query, but after it's cached it's pretty quick (normal behaviour)

However here comes the problem: There are many self-host options for Jackett servers. And some of them have limited RAM (Mine used to have 512MB, now it has only 1GB). And storage is definitely cheaper than RAM.

image
(I run lots of thing in this same EC2 instance)

Describe the solution you'd like

So my idea is to have a toggle to cache using something like MongoDB instead of RAM. It'd still be quicker than re-querying all trackers and wouldn't end up consuming lots of RAM eventually. This could also lead to a perpetual cache, instead of a limited-time cache in RAM, which I'd think is even better.

Describe alternatives you've considered

No response

@ilike2burnthing ilike2burnthing added Enhancement PR Welcome! We would welcome a volunteer to prepare a PR to solve this problem! Core Needs C# labels Jan 22, 2024
@ilike2burnthing
Copy link
Contributor

ilike2burnthing commented Jan 22, 2024

While I agree this would be useful, even just completely changing over to database caching (supporting both it and RAM caching seems unnecessarily complicated), this would be dependent on a contributor or our sole active C# maintainer having time to do so. Don't expect anything quickly.

@hyoretsu
Copy link
Author

Easiest way would be using an ORM https://learn.microsoft.com/en-us/ef/core

The Cache class doesn't seem too complicated to migrate. Unfortunately I have 0 experience with C#.

@abagonhishead
Copy link

abagonhishead commented Feb 11, 2024

I stumbled upon this as I was running the docker container and asking myself why I couldn't store my cache elsewhere, even just in a SQLite database on an AWS bucket or something.

I am a .NET dev. and, unless I'm missing something, I think it would be relatively straightforward to build multiple implementations of the cache class that plug into a multitude of backend solutions (in-memory, Redis, SQL/NoSQL databases, etc.) Right now it's just using a dictionary with a lock, I think, which will be slow.
A lot of the heavy-lifting for this has already been done by .NET. It has caching libraries coming out of the arse.

I will try to have a look at this in the next few months -- I am also busy unfortunately!

@dantebarba
Copy link

my 2 cents: another simpler solution could be to limit the cache storage to a defined amount of RAM. Old cache entries would be dropped from memory. Maybe something like a TTL for every cache entry? the TTL could be configured by env.

@ilike2burnthing
Copy link
Contributor

We already have a cache TTL setting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core Enhancement Needs C# PR Welcome! We would welcome a volunteer to prepare a PR to solve this problem!
Projects
None yet
Development

No branches or pull requests

4 participants