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

[QUESTION] Are there any developments regarding integration with HybridCache and tags support? #273

Open
valentinmarinro opened this issue Jul 18, 2024 · 11 comments

Comments

@valentinmarinro
Copy link

Hi @jodydonetti , we are heavily using tags invalidation in our project, we have a custom implementation based on MemoryCache and Redis and we would really love to switch to FusionCache for the backplane and auto-recovery features, but the missing tags support is a blocker for us.

We saw the thread discussion with Marc Gravel here dotnet/aspnetcore#55308 (comment)

Are there any new developments in this direction, for us only Redis is an option for L2 cache?

Hope I'm not too intrusive with my question :)

@jodydonetti
Copy link
Collaborator

jodydonetti commented Aug 15, 2024

Hi @valentinmarinro and sorry for the delay.

Hi @jodydonetti , we are heavily using tags invalidation in our project, we have a custom implementation based on MemoryCache and Redis and we would really love to switch to FusionCache for the backplane and auto-recovery features, but the missing tags support is a blocker for us.

That's interesting to hear! May I ask which design you used to tackle the issues related to tag invalidation? Did it work well for you?

We saw the thread discussion with Marc Gravel here dotnet/aspnetcore#55308 (comment)

Yep, and as you can see I have not received an official asnwer yet. Having said that I've been able to chat a bit with Marc, but I'm waiting for something official to understand what they've been able to do for .NET 9 and how to move forward.

Basically the point is that preview 7 seemingly just came out, and in general preview 7 is the last preview before the RC1/RC2 cycle, meaning it's the last possible moment where a change in the API surface area is possible: after this point, it's only invisible internal changes, perf boost, and stuff like that.

The problem is that preview 7 does not currently have an official announcement yet (I mean like on DevBlogs), and the only thing I can see is this, but I don't knwo how "final" it is.

So I'm waiting to know something "final".

Anyway, what are your thoughts about the problems I highlighted in my comment over there? Anything to share?

Are there any new developments in this direction, for us only Redis is an option for L2 cache?

Hope I'm not too intrusive with my question :)

Ahah, totally not! Ask freely about anything, I'm here to try to help 🙂

@jodydonetti
Copy link
Collaborator

UPDATE: DevBlogs now has a post about preview 7, but no new info about HybridCache.

@valentinmarinro
Copy link
Author

Hey @jodydonetti , sorry for not responding to you sooner, we were caught in a release cycle and did not had the time to investigate your questions, but I found this proposal for HybridCache in aspnetcore repo: dotnet/aspnetcore#53255 , and tags are there.

namespace Microsoft.Extensions.Caching.Distributed;

public abstract class HybridCache // default concrete impl provided by service registration
{
    protected HybridCache() { }

    // read-thru usage
    public abstract ValueTask<T> GetOrCreateAsync<TState, T>(string key, TState state, Func<TState, CancellationToken, ValueTask<T>> callback, HybridCacheEntryOptions? options = null, ReadOnlyMemory<string> tags = default, CancellationToken cancellationToken = default);
    public virtual ValueTask<T> GetOrCreateAsync<T>(string key, Func<CancellationToken, ValueTask<T>> callback,
    HybridCacheEntryOptions? options = null, ReadOnlyMemory<string> tags = default, CancellationToken cancellationToken = default)
    { /* shared default implementation uses TState/T impl */ }

    // manual usage
    public abstract ValueTask<(bool Exists, T Value)> GetAsync<T>(string key, HybridCacheEntryOptions? options = null, CancellationToken cancellationToken = default);
    public abstract ValueTask SetAsync<T>(string key, T value, HybridCacheEntryOptions? options = null, ReadOnlyMemory<string> tags = default, CancellationToken cancellationToken = default);

    // key invalidation
    public abstract ValueTask RemoveKeyAsync(string key, CancellationToken cancellationToken = default);
    public virtual ValueTask RemoveKeysAsync(ReadOnlyMemory<string> keys, CancellationToken cancellationToken = default)
    { /* shared default implementation uses RemoveKeyAsync */ }

    // tag invalidation
    public virtual ValueTask RemoveTagAsync(string tag, CancellationToken cancellationToken = default)
    { /* shared default implementation uses RemoveTagsAsync */ }
    public virtual ValueTask RemoveTagsAsync(ReadOnlyMemory<string> tags, CancellationToken cancellationToken = default) => default;
}

@jodydonetti
Copy link
Collaborator

jodydonetti commented Sep 25, 2024

Hi, I'm off for vacation ✈️
Will answer properly in 2 weeks!

@jodydonetti
Copy link
Collaborator

Btw the issue you posted has been updated:

image

The timing has changed, and I think not yet finalized.

Will update later anyway!

@HugoVG
Copy link

HugoVG commented Oct 15, 2024

I was wondering if there has been any update on the HybridCache in a while, I tried to use the built in one, but that doesn't seem to support circular references (and they don't seem to expose the STJ options (unlike FusionCache) but I was wondering when I can setup the plug and play with the hybrid cache

@jodydonetti
Copy link
Collaborator

Hi @HugoVG , the base features are already there in an experimental branch, meaning I'm able to use FusionCache as an implementation of HybridCache (of course with some reduced capabilities because of the simpler api surface area).

The big feature that HybridCache in theory will have (not sure if immediately or later on) and that FusionCache is currently missing is tagging support, which is a hairy beast: I'm currently working on that, but have nothing to show right now (but, still, the work is moving forward).

Regarding timing: the initial idea was to release a new version of FusionCache with both tagging support and the HybridCache compatibility at the official release of HybridCache, so in theory at the .NET 9 launch. I'm still pushing for this, but will release it only when it's done well, so it may be a little bit later than that.
Will update more down the road as soon as the pieces will have stabilized.

ps: I was wondering, why can't you just use FusionCache right now for the circular reference thing? It's that you prefer to depend on HybridCache as an interface, or is there something else? Thanks!

@HugoVG
Copy link

HugoVG commented Oct 15, 2024

Regarding timing: the initial idea was to release a new version of FusionCache with both tagging support and the HybridCache compatibility at the official release of HybridCache, so in theory at the .NET 9 launch. I'm still pushing for this, but will release it only when it's done well, so it may be a little bit later than that.

This sounds like a god send 🙏🏻 , can't wait for the the new release

ps: I was wondering, why can't you just use FusionCache right now for the circular reference thing? It's that you prefer to depend on HybridCache as an interface, or is there something else? Thanks!

yes I prefer to depend on HybridCache in most classes (coming from IMemoryCache), since we move a lot of implemantations, where some cases it might just be MemCache and other it is redis or sqlserver

@valentinmarinro
Copy link
Author

Regarding timing: the initial idea was to release a new version of FusionCache with both tagging support and the HybridCache compatibility at the official release of HybridCache, so in theory at the .NET 9 launch. I'm still pushing for this, but will release it only when it's done well, so it may be a little bit later than that. Will update more down the road as soon as the pieces will have stabilized.

Wow, thank you so much @jodydonetti , I can wait to integrate FushionCache with tagging support in our microservices, this will give our microservices a new life and speed :) , we really appreciate the effort you put into this wonderful library.

@jodydonetti
Copy link
Collaborator

UPDATE: it is happening 🥳

Any help would be appreciated!

@jodydonetti
Copy link
Collaborator

Hi all, v2.0.0-preview-1 is out 🥳
This includes Tagging and Clear() support!

🙏 Please, if you can try it out and let me know what you think, how it feels to use it or anything else really: your contribution is essential, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants