Skip to content

utiliread/Caching

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Caching

This library extends the Microsoft.Extensions.Caching libraries with the ability to tag and invalidate cache entries.

The main interface for the tagable cache is:

    public interface ITagable
    {
        Task TagAsync(string key, string[] tags, CancellationToken cancellationToken = default);
        Task InvalidateAsync(string tag, CancellationToken cancellationToken = default);
        Task InvalidateAsync(string[] tags, CancellationToken cancellationToken = default);
    }

The TagAsync() is used to associated one or more tags to an already existing entry located at key. Then later, one can invalidate tags with InvalidateAsync() and in turn delete all keys that were previously tagged.

The tag and invalidation methods are available as extension methods on IDistributedCache.

Lifetime differences compared to Microsoft.Extensions.Caching.Distributed.IDistributedCache

This caching implementation differs from the Redis implementation of the IDistributedCache in one important way, namely when both the sliding expiration and the absolute expiration is defined. The Microsoft implementation allows the sliding expiration to exceed the absolute expiration, where we here treat the absolute expiriation as a finite limit, so the sliding expiration will never refresh an entry to a later time than configured by the absolute expiration.

About

A distributed tagable cache

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published