Skip to content

[API Proposal]: Allow to invalidate only local storage via HybridCache.RemoveAsync #5828

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

Open
gurustron opened this issue Jan 31, 2025 · 1 comment
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation area-caching-hybrid untriaged

Comments

@gurustron
Copy link

Background and motivation

Currently it is impossible to invalidate only local cache without rewriting the value via HybridCache.SetAsync. HybridCache.RemoveAsync will remove entry from both local and remote cache.

The main usage would be to provide user defined workaround until #5517 is designed and implemented and/or lazy approach for invalidation.

API Proposal

public enum HybridCacheRemoveMode 
{
     Full = 0,
     LocalOnly = 1     
}

And extend corresponding methods with it^

public class HybridCache
{
    public abstract ValueTask RemoveAsync(string key, HybridCacheRemoveMode mode = default, CancellationToken cancellationToken = default);
    // ....
}

API Usage

HybridCache hc = ...;
await hc.RemoveAsync("key", HybridCacheRemoveMode.LocalOnly);

Alternative Designs

No response

Risks

No response

@gurustron gurustron added api-suggestion Early API idea and discussion, it is NOT ready for implementation untriaged labels Jan 31, 2025
@jodydonetti
Copy link
Contributor

I would suggest not creating a new type and instead using the already existing HybridCacheEntryOptions for this: of course some members will not make sense on remove, but uniform is better imho (fwiw in FusionCache I did this).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation area-caching-hybrid untriaged
Projects
None yet
Development

No branches or pull requests

2 participants