Skip to content

HybridCache cache not removed by tag #58857

Closed
@mrazvanalex

Description

@mrazvanalex

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

HybridCache RemoveByTagAsync is not removing cache with certain tag when using MemoryCache

Expected Behavior

When running the controller method again, the cache should reset and get new data from myService because the cache should be removed for "identifier" as it has the tag "test" .

The cache is not removed.

Steps To Reproduce

Controller Method

           var tags = new List<string> { id.ToString() };
            var entryOptions = new HybridCacheEntryOptions
            {
                Expiration = TimeSpan.FromMinutes(1),
                LocalCacheExpiration = TimeSpan.FromMinutes(1)
            };

            var result = await _cache.GetOrCreateAsync($"identifier", async get =>
            {
                var result = await _myService.GetData();
                return result;
            }, entryOptions, tags);

Trying to remove cache entry:
` await _cache.RemoveByTagAsync(id.ToString());

Yes, I confirmed that the GUID is the same.

Exceptions (if any)

.NET Version

9.0.100-rc.2.24474.11

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✔️ Resolution: DuplicateResolved as a duplicate of another issueStatus: Resolvedarea-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsfeature-cachingIncludes: StackExchangeRedis and SqlServer distributed caches

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions