ava-innersource / Liquid-Application-Framework-1.0-deprecated

Liquid is a framework to speed up the development of microservices
MIT License
25 stars 14 forks source link

Prefer to use the standard IDistributedCache over ILightCache #107

Open guilhermeluizsp opened 4 years ago

guilhermeluizsp commented 4 years ago

It looks like the ILightCache interface is an abstraction on top over the already abstracted IDistributedCache. Not only it has the same contract but also has the exact same purpose.

https://github.com/Avanade/Liquid-Application-Framework/blob/1d6c37c44fb5bbb6f84ba2f1d1a8a1b3d646c2ad/src/Liquid.Base/Interfaces/Cache/ILightCache.cs#L6-L22

bruno-brant commented 4 years ago

The solution here is to mark ILightCache as obsolete, create an implementation for it that's a wrapper over IDistributedCache, and add a temporary property to Workbench to make sure users that aren't still using injection can access it.

ArtulanezAvanade commented 4 years ago

As metioned on https://github.com/Avanade/Liquid-Application-Framework/issues/108 , the MockCashe, AzureRedis and MemoryCache should implement ILightCache, but as we should prefer to use IDistributedCache, I'm wondering on how these classes are going to handle the methods return's differences as now ILightCache uses and IDistributedCache uses byte[].

bruno-brant commented 4 years ago

Hi @ArtulanezAvanade,

108 is just a low hanging fruit - LightCache could be removed without further impacts on the framework. The issue just mentions that AzureRedis, MemoryCache, MockCache (not familiar with the last one) should be updated to inherited directly IRedisCache. All of this is related to that issue, not this one.

This issue is stating that we should mark LightCache as obsolete since .NET already provides us with the excellent, battle-tested IDistributedCache. In this case, MemoryCache and AzureRedis should also be obsoleted in favor of AddMemoryCache and RedisCache, both Microsoft implementations of IDistributedCache.

UPDATE: About MockCache, I don't really know what is the responsibility of this class and must study it... Without looking into it, I just would say that we could change its inheritance to implement IDistributedCache without much effort.