Binaries for StackExchange.Redis are available on Nuget, and the source is available on Github.
StackExchange.Redis's profiling features are composed of the IProfiler
interface, and the ConnectionMultiplexer.RegisterProfiler(IProfiler)
, ConnectionMultiplexer.BeginProfiling(object)
, ConnectionMultiplexer.FinishProfiling(object)
methods.
Begin and Finish profiling take a context object
so that related commands can be grouped together.
This grouping works by querying your IProfiler
interface for a context object at the start of a command, before any threading shenanigans have happened, and associating that command with a any other commands that have the same context object. Begin must be called with the same context object so StackExchange.Redis knows to start profiling commands with that context object, and Finish is called to stop profiling and return the results.
The Keys()
call will select either the KEYS
or SCAN
command based on the version of the Redis server. Where possible it will prefer the usage of SCAN
which returns an IEnumerable<RedisKey>
and does not block. KEYS
on the other hand will block when scanning the key space.