I am experimenting with the utilization of Redis cache in MVC 6 but I can't get my project to build.
I followed the examples at https://github.com/aspnet/Caching/tree/dev/samples - there is an IDistributedCache sample and a Redis sample. However, it's not entirely clear because the Redis sample isn't a web app.
I have this in my project.json dependencies:
"Microsoft.Framework.Cache.Memory": "1.0.0-beta3",
"Microsoft.Framework.Caching.Distributed": "1.0.0-*",
"Microsoft.Framework.Caching.Redis": "1.0.0-*",
I used this to get my packages:
kpm install Microsoft.Framework.Caching.Distributed
and
kpm install Microsoft.Framework.Caching.Redis
Both commands worked and returned an OK.
And in my startup I'm trying the following:
services.AddSingleton<IMemoryCache, MemoryCache>();
services.AddSingleton<IDistributedCache, RedisCache>();
When trying to build or run, the error given is:
Startup.cs(10,27): error CS0234: The type or namespace name 'Caching' does not exist in the namespace 'Microsoft.Framework' (are you missing an assembly reference?) Startup.cs(11,27): error CS0234: The type or namespace name 'Caching' does not exist in the namespace 'Microsoft.Framework' (are you missing an assembly reference?) Startup.cs(25,35): error CS0246: The type or namespace name 'IDistributedCache' could not be found (are you missing a using directive or an assembly reference?) Startup.cs(25,54): error CS0246: The type or namespace name 'RedisCache' could not be found (are you missing a using directive or an assembly reference?)
Now obviously I have the wrong references - but what are the right references? I'm copying the namespaces directly from the samples? I tried switching to Microsoft.Cache.Distributed and that didn't work either (and conflicted with github)
I have a feeling this is to do with not having the correct K version and maybe that's the way out - upgrading to the latest version. There is a mismatch between Framework.Cache.Memory and Framework.Cache.Distributed and I see github comments relating to namespace changes.
If anyone can point the way out of this maze, much appreciated.