C# Class Whalin.Caching.Memcached.SockIOPool

This class is a connection sockIOPool for maintaning a sockIOPool of persistent connections to memcached servers. The sockIOPool must be initialized prior to use. This should typically be early on in the lifecycle of the application instance.
Exibir arquivo Open project: xianrendzw/LightFramework.Net Class Usage Examples

Public Methods

Method Description
GetSock ( string key ) : SockIO

Returns appropriate SockIO object given string cache key.

GetSock ( string key, object hashCode ) : SockIO

Returns appropriate SockIO object given string cache key and optional hashcode. Trys to get SockIO from sockIOPool. Fails over to additional pools in event of server failure.

SetServers ( ArrayList servers ) : void

Sets the list of all cache servers

SetServers ( string servers ) : void

Sets the list of all cache servers

SetWeights ( ArrayList weights ) : void

sets the list of weights to apply to the server list

SetWeights ( int weights ) : void

sets the list of weights to apply to the server list

Protected Methods

Method Description
AddSocketToPool ( Hashtable pool, string host, SockIO socket ) : void

Adds a socket to a given sockIOPool for the given host. Internal utility method.

ClosePool ( Hashtable pool ) : void

Closes all sockets in the passed in sockIOPool. Internal utility method.

CreateSocket ( string host ) : SockIO

Creates a new SockIO obj for the given server. If server fails to connect, then return null and do not try again until a duration has passed. This duration will grow by doubling after each failed attempt to connect.

SockIOPool ( ) : System

Private Methods

Method Description
CheckIn ( SockIO socket ) : void
CheckIn ( SockIO socket, bool addToAvail ) : void
ClearHostFromPool ( Hashtable pool, string host ) : void
GetConnection ( string host ) : SockIO
GetInstance ( ) : SockIOPool
GetInstance ( String poolName ) : SockIOPool
GetLocalizedString ( string key ) : string
Initialize ( ) : void
NewHashingAlgorithm ( string key ) : int

Internal private hashing method. This is the new hashing algorithm from other clients. Found to be fast and have very good distribution. UPDATE: this is dog slow under java. Maybe under .NET?

OriginalHashingAlgorithm ( string key ) : int

Internal private hashing method. This is the original hashing algorithm from other clients. Found to be slow and have poor distribution.

RemoveSocketFromPool ( Hashtable pool, string host, SockIO socket ) : void
SelfMaintain ( ) : void
Shutdown ( ) : void
StartMaintenanceThread ( ) : void
StopMaintenanceThread ( ) : void

Method Details

AddSocketToPool() protected static method

Adds a socket to a given sockIOPool for the given host. Internal utility method.
protected static AddSocketToPool ( Hashtable pool, string host, SockIO socket ) : void
pool System.Collections.Hashtable
host string host this socket is connected to
socket SockIO socket to add
return void

ClosePool() protected static method

Closes all sockets in the passed in sockIOPool. Internal utility method.
protected static ClosePool ( Hashtable pool ) : void
pool System.Collections.Hashtable
return void

CreateSocket() protected method

Creates a new SockIO obj for the given server. If server fails to connect, then return null and do not try again until a duration has passed. This duration will grow by doubling after each failed attempt to connect.
protected CreateSocket ( string host ) : SockIO
host string host:port to connect to
return SockIO

GetSock() public method

Returns appropriate SockIO object given string cache key.
public GetSock ( string key ) : SockIO
key string hashcode for cache key
return SockIO

GetSock() public method

Returns appropriate SockIO object given string cache key and optional hashcode. Trys to get SockIO from sockIOPool. Fails over to additional pools in event of server failure.
public GetSock ( string key, object hashCode ) : SockIO
key string hashcode for cache key
hashCode object if not null, then the int hashcode to use
return SockIO

SetServers() public method

Sets the list of all cache servers
public SetServers ( ArrayList servers ) : void
servers System.Collections.ArrayList string array of servers [host:port]
return void

SetServers() public method

Sets the list of all cache servers
public SetServers ( string servers ) : void
servers string string array of servers [host:port]
return void

SetWeights() public method

sets the list of weights to apply to the server list
public SetWeights ( ArrayList weights ) : void
weights System.Collections.ArrayList /// This is an int array with each element corresponding to an element /// in the same position in the server string array Servers. ///
return void

SetWeights() public method

sets the list of weights to apply to the server list
public SetWeights ( int weights ) : void
weights int /// This is an int array with each element corresponding to an element /// in the same position in the server string array Servers. ///
return void

SockIOPool() protected method

protected SockIOPool ( ) : System
return System