[QUESTION]: Regarding Multithreading with Ristretto and Cache Sharing Between Programs

Hello,

I’m currently exploring the use of Ristretto for a significant personal project and have been conducting initial tests on simpler use cases to familiarize myself with the library. I have some doubts, however, and the documentation and resources I’ve found online aren’t clear enough so I eventually found this forum.

Multithreading Support: I would like to know if Ristretto is designed to work in multithreaded applications. Specifically, can it handle concurrent access from multiple goroutines effectively? I think it can but I’m not totally sure.

Cache Sharing Between Programs: Additionally, I’m curious about the possiblity of using Ristretto to share a cache between two separate Go programs running as distinct processes. Is this a use case that Ristretto can support?

Thank you for your assistance.

Definitely. Have a look at type ristrettoMap, you’ll see the sync primitives embedded in that structure. And of course the accessors to that type have mutex operations.

I doubt that. Definitely not part of the design… you could try adding that with IPCs or Google’s groupcache… PRs always welcome! But seriously, at that point using a DB (say, Dgraph for instance) is the next architectural boundary you might consider.

1 Like

I understand. Thank you for your quick reply and for the suggestion. I’ll probably simply use Ristretto internally for each process and something on top of it to share data between different programs.