VahidN / EFSecondLevelCache.Core

Entity Framework Core Second Level Caching Library
Apache License 2.0
326 stars 50 forks source link

Error While InvalidateCacheDependencies #19

Closed sacpi closed 6 years ago

sacpi commented 6 years ago

Summary of the issue

I am getting following error after save change call InvalidateCacheDependencies my getting data and caching works perfect also, saving works but

this.GetService < IEFCacheServiceProvider > () does not resolved dependncy

Environment

.net core 2.1 ef core 2.1 rc1 final

The in-use version:
Operating system: 
IDE: (e.g. Visual Studio 2017)

Example code/Steps to reproduce:


Unable to resolve service for type 'EFSecondLevel.Core.Contracts.IEFCacheServiceProvider'. This is often because no database provider has been configured for this DbContext. A provider can be configured by overriding the DbContext.OnConfiguring method or by using AddDbContext on the application service provider. If AddDbContext is used, then also ensure that your DbContext type accepts a DbContextOptions<TContext> object in its constructor and passes it to the base constructor for DbContext.

Output:

Exception message:
Full Stack trace:
VahidN commented 6 years ago
sacpi commented 6 years ago

Thank you I could able resolve the issue now it is working good., it was constructor problem. also, I have updated my input for issue # 17, I have implemented with EF core 2.1 rc1 final and .net core 2.0

One other small question would be if I want configurable cache expiration time when calling method is that possible?, I am using with redis here I have configured .WithExpiration(ExpirationMode.Absolute, TimeSpan.FromMinutes(15))

but it is possible to do pass configuration time method by method or on demand.

dbContext.Set<orders>().Cacheable().ToListAsync() like cache for 15 min and dbContext.Set<ticket>().Cacheable().ToListAsync() cache for 5 min

kefengwei commented 5 years ago

@sacpi do you find a way to pass different time?

lock[bot] commented 4 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related problems.