dotnet / dotnet/aspnetcore

Consider writing an analyzer that produces warnings when using sync APIs on IDistributedCache

Open
#37,991 2 comments 0 reactions 0 assignees View on GitHub
analyzer area-middleware feature-caching
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

`IDistributedCache` has a few synchronous APIs

* https://docs.microsoft.com/dotnet/api/microsoft.extensions.caching.distributed.idistributedcache.get?#Microsoft_Extensions_Caching_Distributed_IDistributedCache_Get_System_String_
* https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.caching.distributed.idistributedcache.refresh
* https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.caching.distributed.idistributedcache.remove
* https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.caching.distributed.idistributedcache.set

In the SqlServer and RedisCache implementations this ends up making blocking calls: e.g. https://github.com/dotnet/aspnetcore/blob/main/src/Caching/SqlServer/src/DatabaseOperations.cs#L54-L62. The proposal is to add an analyzer that warns against the use of these APIs.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.