MichaCo / CacheManager

CacheManager is an open source caching abstraction layer for .NET written in C#. It supports various cache providers and implements many advanced features.
http://cachemanager.michaco.net
Apache License 2.0
2.34k stars 457 forks source link

.NET Standard 2.0 support #221

Open MichaCo opened 6 years ago

MichaCo commented 6 years ago

:update: Version 1.2.0 of CacheManager was released with the 1.x branch targeting .NetStandard 2.0, including the change to the new redis client version.

Breaking Change

I will drop any lower netstandard target in packages which had .netstandard1.x. Also, .NET4.0 support will be removed. Because this is a bigger change, this will be a major version release (2.0), together with upgrading Stackexchange.Redis to 2.x, see #251.

Changes

bbqchickenrobot commented 6 years ago

any news on this? or more poignantly, any where to get the nuget package(s)? :)

MichaCo commented 6 years ago

@bbqchickenrobot you can get the beta packages from the myget feed and give it a try until I release it. I have to do more testing and maybe waiting for 2.1... In case you want to use System.Runtime.Caching on .NET Core, be aware that this is not released by MS yet (I'm using 4.5.0-preview1 atm)...

maldworth commented 6 years ago

So if it looks like system.type will not have binary serialization support, does that mean we will just have to use .WithJsonSerializer() if we are targeting .netstandard2.0?

MichaCo commented 6 years ago

@maldworth You can use any other serializer wich supports .NET Core

MichaCo commented 5 years ago

Main changes to target netstandard 2.0 are done I decided to drop most old targets in the process. E.g. .NET 4.0 will not be available anymore and .netstandard1.x not either. Most of the packages now require .NET461 | netstandard2.0 This allows a lot simplifications in code. I was able to remove almost all ifdefs, which makes testing a lot easier...

I'm not really happy of how some DI things work right now with the DI extension package, so I might actually rework that quite a bit. The idea would be to integrated the Microsoft.Extensions.Di into the CacheManager.Core package. That would become a primary dependency everywhere though. I then would replace my custom initialization via reflection with actually using the DI. I might implement named CacheManager instances/configuartion, too. The existing exposed functionality of CacheFactory should still work though by hiding the DI container...

gautelo commented 5 years ago

Very happy to see this effort! :)

MichaCo commented 5 years ago

I decided to re-release 1.1.2 with just the Redis upgarde and some .NET Standard 2.0 support additions. That's version 1.2.0 which has just been released!

There are no new features or ported functionality to .NETStandard 2.0 in that CacheManager 1.2.0 release. It is exactly the same code as 1.1.2 but with those 2 additions.

Hope that helps!

Miggleness commented 5 years ago

Need help with anything?

asamaha1 commented 5 years ago

Hello, any news on when the 2.x version will be released ? Thank you.

alandillon commented 5 years ago

Any updates?

amirxnz commented 5 years ago

Hi, We really like CacheManager and would like to continue using it in the future. We are in the process of migrating to .net core and this is something that we obviously need to take into consideration. Understood its an open source project and nobody owes anyone anything. We would still kindly ask any update of whether it is still on your personal roadmap?

Thanks!

MichaCo commented 5 years ago

@amirxnz you can totally use the current release with .NET Core and ASP.NET Core, I'm using it for the past 2 years in production.

CM Version 1.2.0 targets .netstandard 2.0, which means you can use it with everything .NET Core and there shouldn't really be any issues... Otherwise, let me know.

amirxnz commented 5 years ago

Hi, Thank you for the answer.

We are having some trouble with the CacheManager.SystemRuntimeCaching? It looks like 1.2 is only for framework 4.5? (https://www.nuget.org/packages/CacheManager.SystemRuntimeCaching)

It is our understanding that this package is needed if we want to keep the results locally in addition to having a redis backplane? Is this correct?

Thanks

MichaCo commented 5 years ago

System.Runtime.Caching has been back ported to .NET Core with some minor breaking changes. The CacheManager package for that one is not released yet, that's correct.

As an alternative, you can use CM with Microsoft.Extensions.Caching instead or just the simple dictionary cache from the CacheManager.Core package. Both work cross plat.

amirxnz commented 5 years ago

Is my understanding correct that iff we use the simple "WithDictionaryHandle()" that means that we need to make sure there are no concurrency issues? However "CM with Microsoft.Extensions.Caching" is already thread-safe since it uses a concurrent dictionary? Are there any downsides to using Microsoft.Extensions.Caching?

Thanks again for all your support, we really appreciate it

MichaCo commented 5 years ago

Hey @amirxnz, no, the simple CM Dictionary handle also uses a ConcurrentDictionary internally and is supposed to be thread-safe. The main difference to Microsoft.Extensions.Caching is that CM Dictionary is faster because it doesn't implement a complicated CacheItem policy thing. And CM Dictionary checks for expired items more frequently. Microsoft.Extensions.Caching does run a check every 2 minutes or so, CM Dictionary does it every 10sec I think.

So, just choose the one you think works best for you.

amirxnz commented 5 years ago

Ok Thanks! I think we'll start with CM Dictionary and see how that treats us.

dengyangxi commented 3 years ago

ask for help

https://github.com/MichaCo/CacheManager/issues/323

I have two projects operating a redis. One is the . Net framework and the other is the . Net CORE

This causes the. Net framework project to write to a cache . . Net core project that cannot be serialized

But. Net core does not have withbinaryserializer. How can I replace it ?

`

if !NETSTANDARD2

/// <summary>
/// Configures a <see cref="BinaryCacheSerializer"/> to be used for serialization and deserialization.
/// </summary>
/// <returns>The builder part.</returns>
public ConfigurationBuilderCachePart WithBinarySerializer()
{
    Configuration.SerializerType = typeof(BinaryCacheSerializer);
    return this;
}

/// <summary>
/// Configures a <see cref="BinaryCacheSerializer"/> to be used for serialization and deserialization.
/// </summary>
/// <param name="serializationFormatter">The <see cref="BinaryFormatter"/> for serialization.</param>
/// <param name="deserializationFormatter">The <see cref="BinaryFormatter"/> for deserialization.</param>
/// <returns>The builder part.</returns>
public ConfigurationBuilderCachePart WithBinarySerializer(BinaryFormatter serializationFormatter, BinaryFormatter deserializationFormatter)
{
    Configuration.SerializerType = typeof(BinaryCacheSerializer);
    Configuration.SerializerTypeArguments = new object[] { serializationFormatter, deserializationFormatter };
    return this;
}

endif

`