I'm trying to create a general-purpose, high-perfo...
# package-development
j
I'm trying to create a general-purpose, high-performance, in-memory cache for custom data in Umbraco sites. Perhaps distributed is the wrong word, maybe "replicated cache" is better. I want my cache to be in memory, eager, and work across scaled instances. Eager because I know what I need to cache ahead of time and/or fetching the data is too slow for UI. In memory for performance - Redis is great, but the TCP overhead is non-trivial and I don't want additional infrastructure for this - it is a software problem. (at least in the sense that an Umbraco site already has the infra that's required to do this, as well as much of the implementation). Working across scaled instances, because Umbraco can scale (so pub/sub and some kind of persistence). Basically, I want a cache that works exactly like the content cache, but I don't want to put Umbraco content in it.
@D_Inventor the MS distributed cache is really just an interface, SQL and redis are external caches in the example. ncache comes close, but it requires me to run on VMs with dedicated software installed (I think to provide the pub/sub) - it's also super expensive. There are some other cache implementations that would do, and I can certainly create my own. I'm struggling with the fact that Umbraco is built around a high-performance replicated in-memory cache, but apparently I can't make use of it.
d
That's understandable, but if I understood Sebastiaan correctly, they have to toss out their current solution soon, and thus it's not recommended to use the Umbraco infrastructure for this.
You can already create the infrastructure around an interface, because as you said: the invalidation is business logic. Then the cache implementation, you can decide on separately
j
Well at least I know early what 2023's never-to-be-finished project is gonna be 😁
Mayyyybe NuCache's replacement will be nicely abstracted and easily configured for custom objects πŸ™
n
Just to echo Sebastiaan once more I took a look at the underlying repo making NuCache possible some time ago and can indeed also report that the underlying project is slowly falling apart. I took some time to multitarget the test project to see the test success on newer dotnet and a bunch failed. It also receives very little development if any. So it's properly not worth the effort in the long run to use NuCache for this. I wrote a little about what I found I relation to the open issue on the repo here if you'd like to see. It also links to the fork where I tried to update the test projects: https://github.com/mamift/CSharpTest.Net.Collections/issues/2
w
Am I understanding this right @Jason ? You want to use CacheRefreshers to notify others servers about something that’s changed (some own data) and not use the existing ones we have. If so I think I have done this before and can take a look tomorrow to help out if that is the case.
j
Yes @Warren Buckley, many thanks for the offer but I've done that before so I'm good with that part. It was more about the persistent cache itself and the prospect of potentially being able to make a nice lightweight package out of it without any chunky dependencies.
w
Ok no worries. I am not sure I fully understand the problem to give anymore pointers right now. My last use of CacheRefreshers was to notify servers that a Form JSON definition had changed and for other servers to update their files they had. (Was trying to patch the problem of Forms being on disk, before it all got moved into the DB).
j
Ah, so that's your code I decompiled πŸ˜‰ You can use cache refreshers for general pub/sub, i.e. not just refreshing caches, as under the hood it's just a way to send JSON blobs to all Umbraco instances using the same db.
w
Yep slightly confusing name called CacheRefreshers but yep your right can send a JSON payload and do whatever really. Sorry for any bad code you may have had to read πŸ€ͺ
n
j
Thank you @nzdev, that does exactly what I want. And my goodness the features...
They've thought of everything!
n
Would be good to get some feedback. I haven't tried it but it looked amazing
j
Yeah, it does. I'll let you know when I've got somewhere with it.
I think I'd want to create a new backplane to see if I can avoid the extra redis infra - but that could be anything really and looks straightforward. Thanks again!