-
-
Notifications
You must be signed in to change notification settings - Fork 84
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
Unable to use Azure Cache for Redis #18
Comments
This error is related to
If you can't set it, just remove that line. |
@VahidN Appreciate the quick response. Great library by the way, I've been relying on it for a while now. When I remove NullReferenceException: at EFCoreSecondLevelCacheInterceptor.EFTableRowsDataReader.GetInt16(Int32 ordinal) |
|
On closer inspection, only It's not just What do you mean by settings for Also, I'm using an Azure SQL database. |
Probably you have a nullable property. It's fixed via #b172fed |
Ah yes - I have many nullable properties. I'm sure that's it. Funny enough, I installed 1.4.0 this morning and noticed you released 1.5.0 shortly afterwards. Will you be pushing another nuget package? Again, your work on this is very much appreciated. |
I just took a quick at your change - would it only affect Redis caching? The in-memory caching seems to be working fine, but I'm not sure if that uses a totally different mechanism. |
|
Just took the package and it does get quite a bit further, but ultimately fails on objects that have a nullable DateTime:
None of my values are stored as DateTimeOffset - they're all defined like this:
|
Try setting: var jss = new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore,
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
TypeNameHandling = TypeNameHandling.Objects, // set this if you have binary data
DateFormatHandling = DateFormatHandling.IsoDateFormat,
DateParseHandling = DateParseHandling.DateTimeOffset,
DateTimeZoneHandling = DateTimeZoneHandling.Utc,
}; |
This is a better solution and converts special data types correctly: var jss = new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore,
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
TypeNameHandling = TypeNameHandling.Objects, // set this if you have binary data
Converters = { new SpecialTypesConverter() }
}; And here is the definition of the |
So strange - I'm still getting the same exception. I should have mentioned this above, but I've been using the following JsonSerializerSettings with EFCoreSecondLevelCache for a long time:
When I'm developing locally I use CacheManager's memory cache, and in other environments use Redis. My memory cache config looks like this, and is currently working fine with the new package:
I'd be surprised if this was serialization related as these serialization settings have been working so reliably for so long, but I'll admit I have no clue what the internals of your package look like. |
The mentioned solution has been tested with this entity will all of the possible data types. This is the final settings for the Redis provider. |
Just in case this helps anyone in the future - My issue with the DateTime conversion all boiled down to the property The proper date type information was being lost as @VahidN points out, and his fix looks to be the correct fix. The issues I was experiencing after implementing the My problem was here:
My unrelated caching code started deserializing to the JObject type after introducing Switching back to My serializer settings now look like this:
I guess the takeaway is to be sure to be careful with your serializer settings. |
Summary of the issue
I just switched from EFCoreSecondLevelCache (the old package) to this new package, and I'm unable to get Redis caching to work using Azure Cache for Redis. I have a Standard Tier Redis cache configured in Azure like so:
The Redis cache config looks like this:
With all of the above, any query run against the DbContext throws this exception:
'ERR unknown command
CONFIG
, with args beginning with:GET
,notify-keyspace-events
, 'Stack Trace:
at StackExchange.Redis.ConnectionMultiplexer.ExecuteSyncImpl[T](Message message, ResultProcessor
1 processor, ServerEndPoint server) in C:\projects\stackexchange-redis\src\StackExchange.Redis\ConnectionMultiplexer.cs:line 2231 at StackExchange.Redis.RedisBase.ExecuteSync[T](Message message, ResultProcessor
1 processor, ServerEndPoint server) in C:\projects\stackexchange-redis\src\StackExchange.Redis\RedisBase.cs:line 54at StackExchange.Redis.RedisServer.ExecuteSync[T](Message message, ResultProcessor
1 processor, ServerEndPoint server) in C:\projects\stackexchange-redis\src\StackExchange.Redis\RedisServer.cs:line 585 at StackExchange.Redis.RedisServer.ConfigGet(RedisValue pattern, CommandFlags flags) in C:\projects\stackexchange-redis\src\StackExchange.Redis\RedisServer.cs:line 152 at CacheManager.Redis.RedisConnectionManager.GetConfiguration(String key) at CacheManager.Redis.RedisCacheHandle
1..ctor(ICacheManagerConfiguration managerConfiguration, CacheHandleConfiguration configuration, ILoggerFactory loggerFactory, ICacheSerializer serializer)The text was updated successfully, but these errors were encountered: