Comments (6)
Change the name of your in-memory cache, to something else:
const string menuLocalCache = "MenuDistributedCache";
Because it's the same as your menuDistributedCache
/redis cache and this FirstOrDefault here thinks it's not a distributed cache, which is true. It's an in-memory cache or the in-memory cache wins first(or default).
from efcoresecondlevelcacheinterceptor.
OMG.... thank you... 😑 This has been driving me nuts.... I just wish it wasn't as simple as PEBCAK... my bad. Thanks for explaining how the lib selects the providers.
from efcoresecondlevelcacheinterceptor.
Try V2.0.0 with this setting:
options.UseEasyCachingCoreProvider(providerName1, isHybridCache: true)
from efcoresecondlevelcacheinterceptor.
Any Luck with the above? I seem to have the same issue.
Ive used the code as per above... but no luck. I keep getting an error
EasyCaching.HybridCache.NotFoundCachingProviderException: Can not found any distributed caching providers.
I have a similar setup to @jasenf's but I have already set the following to:
options.UseEasyCachingCoreProvider(providerName1, isHybridCache: true)
When using easy caching redis / in memory only... it works... but hybrid, not so much.
from efcoresecondlevelcacheinterceptor.
Follow this setup. I use it for my tests.
from efcoresecondlevelcacheinterceptor.
@VahidN I did actually (I found this setup via your tests... but I dont know... just doesnt seem to work)
Im on netcoreapp3.1
and have the following (relevant) modules installed (I havent removed all of the Cache manager modules yet)
<PackageReference Include="CacheManager.StackExchange.Redis" Version="1.2.0" />
<PackageReference Include="EasyCaching.Bus.Redis" Version="0.9.0" />
<PackageReference Include="EasyCaching.HybridCache" Version="0.9.0" />
<PackageReference Include="EasyCaching.InMemory" Version="0.9.0" />
<PackageReference Include="EasyCaching.Serialization.Json" Version="0.9.0" />
<PackageReference Include="EFCoreSecondLevelCacheInterceptor" Version="2.0.0" />
<PackageReference Include="EasyCaching.Core" Version="0.9.0" />
<PackageReference Include="EasyCaching.Redis" Version="0.9.0" />
<PackageReference Include="CacheManager.Core" Version="1.2.0" />
<PackageReference Include="CacheManager.Microsoft.Extensions.Caching.Memory" Version="1.2.0" />
<PackageReference Include="CacheManager.Microsoft.Extensions.Configuration" Version="1.2.0" />
<PackageReference Include="CacheManager.Serialization.Json" Version="1.2.0" />
This is my exact setup:
public virtual void ConfigureDistributedCaching(IServiceCollection services)
{
// localhost / cloud address
var host = Configuration.GetValue<string>("CacheSettings:Server");
// some other internal extension
services.AddDistributedRedisCache(option => { option.Configuration = host; });
const string menuDistributedCache = "MenuDistributedCache";
const string menuLocalCache = "MenuDistributedCache";
const string menuHybridCacheProvider = "MenuHybridCache";
services.AddEFSecondLevelCache(options =>
options
.UseEasyCachingCoreProvider(menuHybridCacheProvider, true)
.CacheAllQueries(CacheExpirationMode.Sliding, TimeSpan.FromMinutes(60))
.DisableLogging(!IsDevelopment)
);
// More info: https://easycaching.readthedocs.io/en/latest/Redis/
services.AddEasyCaching(option =>
{
option.WithJson(x =>
{
x.NullValueHandling = NullValueHandling.Ignore;
x.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
x.TypeNameHandling = TypeNameHandling.Auto;
x.Converters = new List<JsonConverter>() {new SpecialTypesConverter()};
}, "json");
// local
option.UseInMemory(menuLocalCache);
// distributed
option.UseRedis(config =>
{
config.DBConfig.Endpoints.Add(new ServerEndPoint(host, 6379));
config.DBConfig.Database = 14;
config.EnableLogging = IsDevelopment;
config.SerializerName = "json";
}, menuDistributedCache);
// combine local and distributed
option.UseHybrid(config =>
{
config.TopicName = "test-topic";
config.EnableLogging = IsDevelopment;
config.LocalCacheProviderName = menuLocalCache;
config.DistributedCacheProviderName = menuDistributedCache;
}, menuHybridCacheProvider);
// use redis bus
option.WithRedisBus(busConf =>
{
busConf.Database = 15;
busConf.Endpoints.Add(new ServerEndPoint(host, 6379));
busConf.AllowAdmin = true;
});
});
services.AddControllersWithViews();
}
from efcoresecondlevelcacheinterceptor.
Related Issues (20)
- Is there a way to set how many times the app will try and reach the Redis cache? HOT 2
- Make select methods virtual to ease extension of these HOT 1
- Prefix not applied to all generated keys. HOT 1
- Question: Is there plans to support async redis api calls? Using redis sync calls results in thread pool exhaustion and redis timeout issues HOT 1
- Code releases are not tagged HOT 1
- Crash when calling `context.Database.EnsureCreatedAsync()` HOT 1
- There my be a bug? HOT 2
- PostgreSQL hint "FOR UPDATE" causes an IndexOutOfRangeException
- Too much memory is wasted storing in redis HOT 2
- How to use this project with an Aspnetboilerplate project? HOT 1
- Documentation misalignment (most probably) HOT 2
- PostgreSQL unsupported data types HOT 2
- Question about recent changes HOT 1
- JsonSerializer throws exception in EFCacheKeyProvider when using spatial types HOT 1
- Missing time on cache HIT HOT 1
- Support for FusionCache HOT 2
- Requests show up in SQL Server Profiler HOT 2
- distributed cache inconsistencies
- EFCacheKeyProvider fails to serialize parameter value of type IPAddress
- How to set cache key prefix dynamically multi-tenant scenario HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from efcoresecondlevelcacheinterceptor.