Skip to content

Latest commit

 

History

History
34 lines (22 loc) · 2.17 KB

redis.md

File metadata and controls

34 lines (22 loc) · 2.17 KB

REDIS

LEARN

PRIVACY

READING FROM A READ ONLY NODE

Q: https://docs.microsoft.com/en-us/azure/azure-cache-for-redis/cache-high-availability “Normally, a Redis client communicates with the primary node in a Redis cache for all read and write requests. Certain Redis clients can be configured to read from the replica node." What is the best way to do this from a .NET core client and are there any issues/risks?

A: The method for configuring will depend on the Redis client library being used. With the StackExchange.Redis library for example, you can set CommandFlags on a ‘get’ command to prefer (or demand) replica:

var value = await cache.StringGetAsync("key", CommandFlags.PreferReplica);

This should be safe to do, but keep in mind that replica nodes are periodically unavailable during server maintenance. To avoid failures when replicas are down, avoid using “DemandReplica”, and instead use “PreferReplica” so the request can fallback to the primary node if necessary.

MISC