Skip to content
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

AbpMemoryCache slidingExpireTime not working #6486

Closed
titobf opened this issue Jul 9, 2022 · 6 comments · Fixed by #6546
Closed

AbpMemoryCache slidingExpireTime not working #6486

titobf opened this issue Jul 9, 2022 · 6 comments · Fixed by #6546
Assignees
Milestone

Comments

@titobf
Copy link

titobf commented Jul 9, 2022

  • Abp package version: 7.3
  • Your base framework: .Net Core.

Taking a look at the Set method inside AbpMemoryCache (line 41):

        else if (slidingExpireTime.HasValue)
        {
            _memoryCache.Set(key, value, slidingExpireTime.Value);
        }

and then to the corresponding extension method inside MemoryCacheExtensions (line 61):

    public static TItem Set<TItem>(this IMemoryCache cache, object key, TItem value, TimeSpan absoluteExpirationRelativeToNow)
    {
        using ICacheEntry entry = cache.CreateEntry(key);
        entry.AbsoluteExpirationRelativeToNow = absoluteExpirationRelativeToNow;
        entry.Value = value;

        return value;
    }

We can see that AbsoluteExpirationRelativeToNow is being set instead of SlidingExpiration, and those two properties behave differently.

The only workaround I found at the moment is to handle MemoryCache directly, without going through ABP's ICacheManager.

@ismcagdas ismcagdas added this to the v7.4 milestone Jul 12, 2022
@ismcagdas
Copy link
Member

@titobf thanks, we will check this.

@Omital
Copy link

Omital commented Aug 30, 2022

This is a serious issue for my project. How can I solve this problem temporarily?

@ismcagdas
Copy link
Member

@Omital I'm not sure but you can try to use suggestion here #6486 (comment)

@ismcagdas
Copy link
Member

@titobf could you check if this PR solves your problem #6546 ?

@titobf
Copy link
Author

titobf commented Sep 20, 2022

Hi @ismcagdas. Sorry, but the project is from my work and we just ended up using MemoryCache. Nevertheless, the file changes on your PR seem correct.

@ismcagdas
Copy link
Member

Thanks a lot. I will test it as well 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants