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.
Afficher le fichier Open project: xianrendzw/LightFramework.Net Class Usage Examples

Méthodes publiques

Méthode 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

Méthodes protégées

Méthode 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

Méthode 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 méthode

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
Résultat void

ClosePool() protected static méthode

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

CreateSocket() protected méthode

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
Résultat SockIO

GetSock() public méthode

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

GetSock() public méthode

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
Résultat SockIO

SetServers() public méthode

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

SetServers() public méthode

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

SetWeights() public méthode

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. ///
Résultat void

SetWeights() public méthode

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. ///
Résultat void

SockIOPool() protected méthode

protected SockIOPool ( ) : System
Résultat System