Skip to content

Add documentation on L1 cache getting out of sync when using multiple instances #34083

@dukesteen

Description

@dukesteen

Description

The current documentation for HybridCache does not adequately warn developers about the risk of L1 cache getting out of sync when invalidating cache entries from another instance. Consider the following example:

Instance 1
 - memorycache with tenant id 1 inside
 - redis cache nothing inside
Instance 2
 - memorycache with nothing inside
 - redis cache also nothing inside

Now instance 2 does an update on the tenant and invalidates both the redis and local cache, which gives you the following situation

Instance 1
 - memorycache with tenant id 1 inside
 - redis cache also has tenant id 1 inside
Instance 2
 - memorycache with tenant id 1 inside
 - redis cache also has tenant id 1 inside

Instance 1's layer 1 cache is now out of sync, and can respond to requests with the wrong data. This can be catastrophic if instance 2 removed access for a user while instance 1 is still serving requests for this user as if they were active.

Related issue: dotnet/extensions#7098

Page URL

https://learn.microsoft.com/en-us/aspnet/core/performance/caching/hybrid?view=aspnetcore-9.0

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/performance/caching/hybrid.md

Document ID

fdd3c6f2-c3f4-6fc7-0928-0b18ba9297cf

Article author

@tdykstra

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions