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.35k stars 456 forks source link

Does CacheManager.Serialization.Json.GzJsonCacheSerializer support string values? #207

Open andreymir opened 6 years ago

andreymir commented 6 years ago

Here is my cache configuration

                        cacheConfigBuilder
                            .WithRedisConfiguration("redis", redisConnection.Value)
                            .WithUpdateMode(CacheUpdateMode.Up)
                            .WithSerializer(typeof(CacheManager.Serialization.Json.GzJsonCacheSerializer))
                            .WithMaxRetries(1)
                            .WithRetryTimeout(2)
                            .WithRedisBackplane("redis", channelName: $"{environment.EnvironmentName}-backplane")
                            .WithRedisCacheHandle("redis", isBackplaneSource: true);

When I put string into the cache it seems it is not compressed.

MichaCo commented 6 years ago

Yeah, primitives do not have to be serialized, that's why a string doesn't go through the serializer/gz compression. You could easily do that yourself though and just cache the compressed byte array?

andreymir commented 6 years ago

I just wrapped a sting into a custom object. Maybe this could be mentioned in the documentation http://cachemanager.michaco.net/documentation/CacheManagerSerialization?

MichaCo commented 6 years ago

Yup, documentation should probably have a statement about that