Class ConnectionMultiplexer
- Namespace
- StackExchange.Redis
- Assembly
- StackExchange.Redis.StrongName.dll
Represents an inter-related group of connections to redis servers
public sealed class ConnectionMultiplexer : IConnectionMultiplexer, IDisposable
- Inheritance
-
ConnectionMultiplexer
- Implements
- Inherited Members
Properties
ClientName
Gets the client-name that will be used on all new connections
public string ClientName { get; }
Property Value
Configuration
Gets the configuration of the connection
public string Configuration { get; }
Property Value
Factory
Provides a way of overriding the default Task Factory. If not set, it will use the default Task.Factory. Useful when top level code sets it's own factory which may interfere with Redis queries.
public static TaskFactory Factory { get; set; }
Property Value
IncludeDetailInExceptions
Should exceptions include identifiable details? (key names, additional .Data annotations)
public bool IncludeDetailInExceptions { get; set; }
Property Value
IncludePerformanceCountersInExceptions
Should exceptions include performance counter details? (CPU usage, etc - note that this can be problematic on some platforms)
public bool IncludePerformanceCountersInExceptions { get; set; }
Property Value
IsConnected
Indicates whether any servers are connected
public bool IsConnected { get; }
Property Value
OperationCount
The number of operations that have been performed on all connections
public long OperationCount { get; }
Property Value
PreserveAsyncOrder
Gets or sets whether asynchronous operations should be invoked in a way that guarantees their original delivery order
public bool PreserveAsyncOrder { get; set; }
Property Value
StormLogThreshold
Limit at which to start recording unusual busy patterns (only one log will be retained at a time; set to a negative value to disable this feature)
public int StormLogThreshold { get; set; }
Property Value
TimeoutMilliseconds
Gets the timeout associated with the connections
public int TimeoutMilliseconds { get; }
Property Value
Methods
BeginProfiling(object)
Begins profiling for the given context.
If the same context object is returned by the registered IProfiler, the IProfiledCommands will be associated with each other.
Call FinishProfiling with the same context to get the assocated commands.
Note that forContext cannot be a WeakReference or a WeakReference<T>
public void BeginProfiling(object forContext)
Parameters
forContext
object
Close(bool)
Close all connections and release all resources associated with this object
public void Close(bool allowCommandsToComplete = true)
Parameters
allowCommandsToComplete
bool
CloseAsync(bool)
Close all connections and release all resources associated with this object
public Task CloseAsync(bool allowCommandsToComplete = true)
Parameters
allowCommandsToComplete
bool
Returns
Configure(TextWriter)
Reconfigure the current connections based on the existing configuration
public bool Configure(TextWriter log = null)
Parameters
log
TextWriter
Returns
ConfigureAsync(TextWriter)
Reconfigure the current connections based on the existing configuration
public Task<bool> ConfigureAsync(TextWriter log = null)
Parameters
log
TextWriter
Returns
Connect(ConfigurationOptions, TextWriter)
Create a new ConnectionMultiplexer instance
public static ConnectionMultiplexer Connect(ConfigurationOptions configuration, TextWriter log = null)
Parameters
configuration
ConfigurationOptionslog
TextWriter
Returns
Connect(string, TextWriter)
Create a new ConnectionMultiplexer instance
public static ConnectionMultiplexer Connect(string configuration, TextWriter log = null)
Parameters
configuration
stringlog
TextWriter
Returns
ConnectAsync(ConfigurationOptions, TextWriter)
Create a new ConnectionMultiplexer instance
public static Task<ConnectionMultiplexer> ConnectAsync(ConfigurationOptions configuration, TextWriter log = null)
Parameters
configuration
ConfigurationOptionslog
TextWriter
Returns
ConnectAsync(string, TextWriter)
Create a new ConnectionMultiplexer instance
public static Task<ConnectionMultiplexer> ConnectAsync(string configuration, TextWriter log = null)
Parameters
configuration
stringlog
TextWriter
Returns
Dispose()
Release all resources associated with this object
public void Dispose()
ExportConfiguration(Stream, ExportOptions)
Write the configuration of all servers to an output stream
public void ExportConfiguration(Stream destination, ExportOptions options = (ExportOptions)-1)
Parameters
destination
Streamoptions
ExportOptions
FinishProfiling(object, bool)
Stops profiling for the given context, returns all IProfiledCommands associated.
By default this may do a sweep for dead profiling contexts, you can disable this by passing "allowCleanupSweep: false".
public ProfiledCommandEnumerable FinishProfiling(object forContext, bool allowCleanupSweep = true)
Parameters
Returns
GetCounters()
Get summary statistics associates with this server
public ServerCounters GetCounters()
Returns
GetDatabase(int, object)
Obtain an interactive connection to a database inside redis
public IDatabase GetDatabase(int db = -1, object asyncState = null)
Parameters
Returns
GetEndPoints(bool)
Gets all endpoints defined on the server
public EndPoint[] GetEndPoints(bool configuredOnly = false)
Parameters
configuredOnly
bool
Returns
- EndPoint[]
GetServer(EndPoint, object)
Obtain a configuration API for an individual server
public IServer GetServer(EndPoint endpoint, object asyncState = null)
Parameters
Returns
GetServer(IPAddress, int)
Obtain a configuration API for an individual server
public IServer GetServer(IPAddress host, int port)
Parameters
Returns
GetServer(string, int, object)
Obtain a configuration API for an individual server
public IServer GetServer(string host, int port, object asyncState = null)
Parameters
Returns
GetServer(string, object)
Obtain a configuration API for an individual server
public IServer GetServer(string hostAndPort, object asyncState = null)
Parameters
Returns
GetStatus()
Provides a text overview of the status of all connections
public string GetStatus()
Returns
GetStatus(TextWriter)
Provides a text overview of the status of all connections
public void GetStatus(TextWriter log)
Parameters
log
TextWriter
GetStormLog()
Obtains the log of unusual busy patterns
public string GetStormLog()
Returns
GetSubscriber(object)
Obtain a pub/sub subscriber connection to the specified server
public ISubscriber GetSubscriber(object asyncState = null)
Parameters
asyncState
object
Returns
HashSlot(RedisKey)
Compute the hash-slot of a specified key
public int HashSlot(RedisKey key)
Parameters
key
RedisKey
Returns
PublishReconfigure(CommandFlags)
Request all compatible clients to reconfigure or reconnect
public long PublishReconfigure(CommandFlags flags = CommandFlags.None)
Parameters
flags
CommandFlags
Returns
- long
The number of instances known to have received the message (however, the actual number can be higher; returns -1 if the operation is pending)
PublishReconfigureAsync(CommandFlags)
Request all compatible clients to reconfigure or reconnect
public Task<long> PublishReconfigureAsync(CommandFlags flags = CommandFlags.None)
Parameters
flags
CommandFlags
Returns
- Task<long>
The number of instances known to have received the message (however, the actual number can be higher)
RegisterProfiler(IProfiler)
Sets an IProfiler instance for this ConnectionMultiplexer.
An IProfiler instances is used to determine which context to associate an IProfiledCommand with. See BeginProfiling(object) and FinishProfiling(object) for more details.
public void RegisterProfiler(IProfiler profiler)
Parameters
profiler
IProfiler
ResetStormLog()
Resets the log of unusual busy patterns
public void ResetStormLog()
ToString()
See Object.ToString()
public override string ToString()
Returns
Wait(Task)
Wait for a given asynchronous operation to complete (or timeout)
public void Wait(Task task)
Parameters
task
Task
WaitAll(params Task[])
Wait for the given asynchronous operations to complete (or timeout)
public void WaitAll(params Task[] tasks)
Parameters
tasks
Task[]
Wait<T>(Task<T>)
Wait for a given asynchronous operation to complete (or timeout)
public T Wait<T>(Task<T> task)
Parameters
task
Task<T>
Returns
- T
Type Parameters
T
Events
ConfigurationChanged
Raised when configuration changes are detected
public event EventHandler<EndPointEventArgs> ConfigurationChanged
Event Type
ConfigurationChangedBroadcast
Raised when nodes are explicitly requested to reconfigure via broadcast; this usually means master/slave changes
public event EventHandler<EndPointEventArgs> ConfigurationChangedBroadcast
Event Type
ConnectionFailed
Raised whenever a physical connection fails
public event EventHandler<ConnectionFailedEventArgs> ConnectionFailed
Event Type
ConnectionRestored
Raised whenever a physical connection is established
public event EventHandler<ConnectionFailedEventArgs> ConnectionRestored
Event Type
ErrorMessage
A server replied with an error message;
public event EventHandler<RedisErrorEventArgs> ErrorMessage
Event Type
HashSlotMoved
Raised when a hash-slot has been relocated
public event EventHandler<HashSlotMovedEventArgs> HashSlotMoved
Event Type
InternalError
Raised whenever an internal error occurs (this is primarily for debugging)
public event EventHandler<InternalErrorEventArgs> InternalError