RedisForNetDevelopers | Source code for blog post on Redis for .NET Developer Series | Blog library
kandi X-RAY | RedisForNetDevelopers Summary
kandi X-RAY | RedisForNetDevelopers Summary
Source code for blog post on Redis for .NET Developer Series To read more visit
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of RedisForNetDevelopers
RedisForNetDevelopers Key Features
RedisForNetDevelopers Examples and Code Snippets
Community Discussions
Trending Discussions on RedisForNetDevelopers
QUESTION
I have a Redis store similar to this one. My problem is, since I am using .Net Core, on line 15, I should use configuration object that I normally inject in the constructor.
However, one cannot inject the configuration object in the static constructor, as static constructor should be parameterless in C#.
I tried adding a static method to initialise the config object, but then the constructor throws NullReferenceException
because obviously the ctor is still called first, before the Init method, and it needs the config object... so what to do?
Doesn't seem like a good workaround.
...ANSWER
Answered 2020-Oct-11 at 10:03Instead of doing all that work with statics and trying to get it to work (hint: it'd never work with a static constructor), I'd suggest you to move to newer patterns and use DI correctly.
If you don't really need the lazyness, this is as simple as injecting IConnectionMultiplexer
:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install RedisForNetDevelopers
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page