I want caching to maximize response times and database usage. I am trying to determine if I should use the csharp client or Redis or both in my new .netcore services API. It seems to me I should just use Redis. Anyone know if I should use both for some reason? Optionally, Should I just use the service client to handle the caching and ignore Redis?
1 Answers
These 2 libraries are unrelated, the C# Service Clients enables a Typed API to access your Services from .NET Apps whilst the ServiceStack.Redis provides a Typed API to access the Redis in memory database from .NET.
What you need is dependent on your use-case, if you're using load-balanced servers than using a distributed caching provider like Redis is recommended so all load-balanced app servers utilize the same distributed cache and user sessions, if you're only using a single server than a utilizing a distributed Redis cache wont be as useful as the default In Memory Cache is going to be faster.
The C# .NET Service Clients don't have any caching in-built, in order to utilize caching in Service Clients your services would need to utilize HTTP Caching which returns HTTP caching primitive instructions that maintain "client caches" when using Cache Aware Service Clients.
If you're only using "Server Caching" functionality like [CacheResponse(Duration)] attribute or any of the ToOptimizedResult*
APIs then the cache is only on the Server which is transparent to any HTTP Client which would all access the same "Server Cached Responses".

- 141,670
- 29
- 246
- 390
-
Thanks, mythz. I read this and assumed it was all cache enabled. It kind of stands out as the first item under Service Client... Cache Aware Service Clients When caching is enabled on Services, the Cache-aware Service Clients can dramatically improve performance by eliminating server requests entirely as well as reducing bandwidth for re-validated requests. – Steve Coleman Dec 03 '18 at 15:25