ServiceStack.Redis Enqueue item Dequeue up to maxBatchSize items from queue Distributed lock interface Wrap the common redis list operations under a IList[string] interface. The client wraps the native redis operations into a more readable c# API. Where possible these operations are also exposed in common c# interfaces, e.g. RedisClient.Lists => IList[string] RedisClient.Sets => ICollection[string] This class contains all the common operations for the RedisClient. The client contains a 1:1 mapping of c# methods to redis operations of the same name. Not threadsafe use a pooled manager Command to set multuple binary safe arguments reset buffer index in send buffer Requires custom result parsing Number of results Used to manage connection pooling Gets or sets object key prefix. Interface to Alchemy DB http://code.google.com/p/alchemydatabase/ Native interface to Alchemy DB Creates a new instance of the Redis Client from NewFactoryFn. Returns key with automatic object id detection in provided value with generic type. Returns key with explicit object id. Returns key with explicit object type and id. Allows you to get Redis value operations to operate against POCO types. Use this to share the same redis connection with another The client. Redis operation (transaction/pipeline) that allows queued commands to be completed Wrap the common redis set operations under a ICollection[string] interface. Adds support for Redis Transactions (i.e. MULTI/EXEC/DISCARD operations). Pipeline for redis typed client Queue of commands for redis typed client Put "QUEUED" messages at back of queue Issue exec command (not queued) callback for after result count is read in distributed work item queue. Each message must have an associated work item id. For a given id, all work items are guaranteed to be processed in the order in which they are received. distributed work item queue. Each message must have an associated work item id. For a given id, all work items are guaranteed to be processed in the order in which they are received. distributed work item queue Enqueue item in priority queue corresponding to workItemId identifier Preprare next work item id for dequeueing Dequeue up to maxBatchSize items from queue corresponding to workItemId identifier. Once this method is called, or will not return any items for workItemId until the dequeue lock returned is unlocked. Replace existing work item in workItemId queue Queue incoming messages Must call this periodically to move work items from priority queue to pending queue Replace existing work item in workItemId queue Pop items from list Force release of locks held by crashed servers release lock held by crashed server true if lock is released, either by this method or by another client; false otherwise Unlock work item id, so other servers can process items for this id This class manages a write lock for a local readers/writer lock, using the Resource Acquisition Is Initialization pattern RAII disposal acquire distributed, non-reentrant lock on key global key for this lock timeout for acquiring lock timeout for lock, in seconds (stored as value against lock key) unlock key distributed work item queue. Messages are processed in chronological order Enqueue incoming messages Dequeue next batch of work items Redis command that does not get queued Ignore dispose on RedisClientsManager, which should be registered as a singleton A complete redis command, with method to send command, receive response, and run callback on success or failure Locking strategy interface Optimized implementation. Primitive types are manually serialized, the rest are serialized using binary serializer />. serialize/deserialize arbitrary objects (objects must be serializable) Serialize object to buffer serializable object Deserialize buffer to object byte array to deserialize serialize value and wrap with Unwrap object wrapped in manages a "region" in the redis key space namespace can be cleared by incrementing the generation get current generation set new generation redis key for generation get redis key that holds all namespace keys get global cache key get global key inside of this namespace prefixes can be added for name deconfliction replace UniqueCharacter with its double, to avoid name clash get locking strategy Represents a generic collection of key/value pairs that are ordered independently of the key and value. The type of the keys in the dictionary The type of the values in the dictionary Represents a generic collection of key/value pairs that are ordered independently of the key and value. The type of the keys in the dictionary The type of the values in the dictionary Adds an entry with the specified key and value into the IOrderedDictionary<TKey,TValue> collection with the lowest available index. The key of the entry to add. The value of the entry to add. The index of the newly added entry You can also use the property to add new elements by setting the value of a key that does not exist in the IOrderedDictionary<TKey,TValue> collection; however, if the specified key already exists in the IOrderedDictionary<TKey,TValue>, setting the property overwrites the old value. In contrast, the method does not modify existing elements. An element with the same key already exists in the IOrderedDictionary<TKey,TValue> The IOrderedDictionary<TKey,TValue> is read-only.
-or-
The IOrderedDictionary<TKey,TValue> has a fized size.
Inserts a new entry into the IOrderedDictionary<TKey,TValue> collection with the specified key and value at the specified index. The zero-based index at which the element should be inserted. The key of the entry to add. The value of the entry to add. The value can be if the type of the values in the dictionary is a reference type. is less than 0.
-or-
is greater than .
An element with the same key already exists in the IOrderedDictionary<TKey,TValue>. The IOrderedDictionary<TKey,TValue> is read-only.
-or-
The IOrderedDictionary<TKey,TValue> has a fized size.
Gets or sets the value at the specified index. The zero-based index of the value to get or set. The value of the item at the specified index. is less than 0.
-or-
is equal to or greater than .
Initializes a new instance of the OrderedDictionary<TKey,TValue> class. Initializes a new instance of the OrderedDictionary<TKey,TValue> class using the specified initial capacity. The initial number of elements that the OrderedDictionary<TKey,TValue> can contain. is less than 0 Initializes a new instance of the OrderedDictionary<TKey,TValue> class using the specified comparer. The IEqualityComparer<TKey> to use when comparing keys, or to use the default EqualityComparer<TKey> for the type of the key. Initializes a new instance of the OrderedDictionary<TKey,TValue> class using the specified initial capacity and comparer. The initial number of elements that the OrderedDictionary<TKey,TValue> collection can contain. The IEqualityComparer<TKey> to use when comparing keys, or to use the default EqualityComparer<TKey> for the type of the key. is less than 0 Converts the object passed as a key to the key type of the dictionary The key object to check The key object, cast as the key type of the dictionary is . The key type of the OrderedDictionary<TKey,TValue> is not in the inheritance hierarchy of . Converts the object passed as a value to the value type of the dictionary The object to convert to the value type of the dictionary The value object, converted to the value type of the dictionary is , and the value type of the OrderedDictionary<TKey,TValue> is a value type. The value type of the OrderedDictionary<TKey,TValue> is not in the inheritance hierarchy of . Inserts a new entry into the OrderedDictionary<TKey,TValue> collection with the specified key and value at the specified index. The zero-based index at which the element should be inserted. The key of the entry to add. The value of the entry to add. The value can be if the type of the values in the dictionary is a reference type. is less than 0.
-or-
is greater than .
is . An element with the same key already exists in the OrderedDictionary<TKey,TValue>.
Inserts a new entry into the OrderedDictionary<TKey,TValue> collection with the specified key and value at the specified index. The zero-based index at which the element should be inserted. The key of the entry to add. The value of the entry to add. The value can be if the type of the values in the dictionary is a reference type. is less than 0.
-or-
is greater than .
is .
-or-
is , and the value type of the OrderedDictionary<TKey,TValue> is a value type.
The key type of the OrderedDictionary<TKey,TValue> is not in the inheritance hierarchy of .
-or-
The value type of the OrderedDictionary<TKey,TValue> is not in the inheritance hierarchy of .
-or-
An element with the same key already exists in the OrderedDictionary<TKey,TValue>.
Removes the entry at the specified index from the OrderedDictionary<TKey,TValue> collection. The zero-based index of the entry to remove. is less than 0.
-or-
index is equal to or greater than .
Adds an entry with the specified key and value into the OrderedDictionary<TKey,TValue> collection with the lowest available index. The key of the entry to add. The value of the entry to add. This value can be . A key cannot be , but a value can be. You can also use the property to add new elements by setting the value of a key that does not exist in the OrderedDictionary<TKey,TValue> collection; however, if the specified key already exists in the OrderedDictionary<TKey,TValue>, setting the property overwrites the old value. In contrast, the method does not modify existing elements. is An element with the same key already exists in the OrderedDictionary<TKey,TValue> Adds an entry with the specified key and value into the OrderedDictionary<TKey,TValue> collection with the lowest available index. The key of the entry to add. The value of the entry to add. This value can be . The index of the newly added entry A key cannot be , but a value can be. You can also use the property to add new elements by setting the value of a key that does not exist in the OrderedDictionary<TKey,TValue> collection; however, if the specified key already exists in the OrderedDictionary<TKey,TValue>, setting the property overwrites the old value. In contrast, the method does not modify existing elements. is An element with the same key already exists in the OrderedDictionary<TKey,TValue> Adds an entry with the specified key and value into the OrderedDictionary<TKey,TValue> collection with the lowest available index. The key of the entry to add. The value of the entry to add. This value can be . is .
-or-
is , and the value type of the OrderedDictionary<TKey,TValue> is a value type.
The key type of the OrderedDictionary<TKey,TValue> is not in the inheritance hierarchy of .
-or-
The value type of the OrderedDictionary<TKey,TValue> is not in the inheritance hierarchy of .
Removes all elements from the OrderedDictionary<TKey,TValue> collection. The capacity is not changed as a result of calling this method. Determines whether the OrderedDictionary<TKey,TValue> collection contains a specific key. The key to locate in the OrderedDictionary<TKey,TValue> collection. if the OrderedDictionary<TKey,TValue> collection contains an element with the specified key; otherwise, . is Determines whether the OrderedDictionary<TKey,TValue> collection contains a specific key. The key to locate in the OrderedDictionary<TKey,TValue> collection. if the OrderedDictionary<TKey,TValue> collection contains an element with the specified key; otherwise, . is The key type of the OrderedDictionary<TKey,TValue> is not in the inheritance hierarchy of . Returns the zero-based index of the specified key in the OrderedDictionary<TKey,TValue> The key to locate in the OrderedDictionary<TKey,TValue> The zero-based index of , if is found in the OrderedDictionary<TKey,TValue>; otherwise, -1 This method performs a linear search; therefore it has a cost of O(n) at worst. Removes the entry with the specified key from the OrderedDictionary<TKey,TValue> collection. The key of the entry to remove if the key was found and the corresponding element was removed; otherwise, Removes the entry with the specified key from the OrderedDictionary<TKey,TValue> collection. The key of the entry to remove Copies the elements of the OrderedDictionary<TKey,TValue> elements to a one-dimensional Array object at the specified index. The one-dimensional object that is the destination of the objects copied from the OrderedDictionary<TKey,TValue>. The must have zero-based indexing. The zero-based index in at which copying begins. The method preserves the order of the elements in the OrderedDictionary<TKey,TValue> Gets the value associated with the specified key. The key of the value to get. When this method returns, contains the value associated with the specified key, if the key is found; otherwise, the default value for the type of . This parameter can be passed uninitialized. if the OrderedDictionary<TKey,TValue> contains an element with the specified key; otherwise, . Adds the specified value to the OrderedDictionary<TKey,TValue> with the specified key. The KeyValuePair<TKey,TValue> structure representing the key and value to add to the OrderedDictionary<TKey,TValue>. Determines whether the OrderedDictionary<TKey,TValue> contains a specific key and value. The KeyValuePair<TKey,TValue> structure to locate in the OrderedDictionary<TKey,TValue>. if is found in the OrderedDictionary<TKey,TValue>; otherwise, . Copies the elements of the OrderedDictionary<TKey,TValue> to an array of type , starting at the specified index. The one-dimensional array of type KeyValuePair<TKey,TValue> that is the destination of the KeyValuePair<TKey,TValue> elements copied from the OrderedDictionary<TKey,TValue>. The array must have zero-based indexing. The zero-based index in at which copying begins. Removes a key and value from the dictionary. The KeyValuePair<TKey,TValue> structure representing the key and value to remove from the OrderedDictionary<TKey,TValue>. if the key and value represented by is successfully found and removed; otherwise, . This method returns if is not found in the OrderedDictionary<TKey,TValue>. Gets the dictionary object that stores the keys and values The dictionary object that stores the keys and values for the OrderedDictionary<TKey,TValue> Accessing this property will create the dictionary object if necessary Gets the list object that stores the key/value pairs. The list object that stores the key/value pairs for the OrderedDictionary<TKey,TValue> Accessing this property will create the list object if necessary. Gets or sets the value at the specified index. The zero-based index of the value to get or set. The value of the item at the specified index. is less than 0.
-or-
index is equal to or greater than .
Gets or sets the value at the specified index. The zero-based index of the value to get or set. The value of the item at the specified index. is less than 0.
-or-
index is equal to or greater than .
is a null reference, and the value type of the OrderedDictionary<TKey,TValue> is a value type. The value type of the OrderedDictionary<TKey,TValue> is not in the inheritance hierarchy of .
Gets a value indicating whether the OrderedDictionary<TKey,TValue> has a fixed size. if the OrderedDictionary<TKey,TValue> has a fixed size; otherwise, . The default is . Gets a value indicating whether the OrderedDictionary<TKey,TValue> collection is read-only. if the OrderedDictionary<TKey,TValue> is read-only; otherwise, . The default is . A collection that is read-only does not allow the addition, removal, or modification of elements after the collection is created. A collection that is read-only is simply a collection with a wrapper that prevents modification of the collection; therefore, if changes are made to the underlying collection, the read-only collection reflects those changes. Gets an object containing the keys in the OrderedDictionary<TKey,TValue>. An object containing the keys in the OrderedDictionary<TKey,TValue>. The returned object is not a static copy; instead, the collection refers back to the keys in the original OrderedDictionary<TKey,TValue>. Therefore, changes to the OrderedDictionary<TKey,TValue> continue to be reflected in the key collection. Gets an object containing the values in the OrderedDictionary<TKey,TValue> collection. An object containing the values in the OrderedDictionary<TKey,TValue> collection. The returned object is not a static copy; instead, the refers back to the values in the original OrderedDictionary<TKey,TValue> collection. Therefore, changes to the OrderedDictionary<TKey,TValue> continue to be reflected in the . Gets or sets the value with the specified key. The key of the value to get or set. The value associated with the specified key. If the specified key is not found, attempting to get it returns , and attempting to set it creates a new element using the specified key. Gets or sets the value with the specified key. The key of the value to get or set. The value associated with the specified key. If the specified key is not found, attempting to get it returns , and attempting to set it creates a new element using the specified key. Gets the number of key/values pairs contained in the OrderedDictionary<TKey,TValue> collection. The number of key/value pairs contained in the OrderedDictionary<TKey,TValue> collection. Gets a value indicating whether access to the OrderedDictionary<TKey,TValue> object is synchronized (thread-safe). This method always returns false. Gets an object that can be used to synchronize access to the OrderedDictionary<TKey,TValue> object. An object that can be used to synchronize access to the OrderedDictionary<TKey,TValue> object. Gets an ICollection<TKey> object containing the keys in the OrderedDictionary<TKey,TValue>. An ICollection<TKey> object containing the keys in the OrderedDictionary<TKey,TValue>. The returned ICollection<TKey> object is not a static copy; instead, the collection refers back to the keys in the original OrderedDictionary<TKey,TValue>. Therefore, changes to the OrderedDictionary<TKey,TValue> continue to be reflected in the key collection. Gets an ICollection<TValue> object containing the values in the OrderedDictionary<TKey,TValue>. An ICollection<TValue> object containing the values in the OrderedDictionary<TKey,TValue>. The returned ICollection<TKey> object is not a static copy; instead, the collection refers back to the values in the original OrderedDictionary<TKey,TValue>. Therefore, changes to the OrderedDictionary<TKey,TValue> continue to be reflected in the value collection. Wrap the common redis set operations under a ICollection[string] interface. Wrap the common redis set operations under a ICollection[string] interface. wraps a serialized representation of an object Initializes a new instance of . Custom item data. The serialized item. The data representing the item being stored/retireved. Flags set for this instance. Useful wrapper IRedisClientsManager to cut down the boiler plat of most IRedisClient access Wrap the common redis set operations under a ICollection[string] interface. Adds a node and maps points across the circle node to add An arbitrary number, specifies how often it occurs relative to other targets. A variation of Binary Search algorithm. Given a number, matches the next highest number from the sorted array. If a higher number does not exist, then the first number in the array is returned. a sorted array to perform the search number to find the next highest number against next highest number Given a key, generates an unsigned 64 bit hash code using MD5 Redis-specific exception. Thrown if unable to connect to Redis server due to socket exception, for example. distributed lock class that follows the Resource Allocation Is Initialization pattern Lock in seconds in seconds unlock Adds support for Redis Transactions (i.e. MULTI/EXEC/DISCARD operations). General purpose pipeline Flush send buffer, and read responses Put "QUEUED" messages at back of queue Issue exec command (not queued) callback for after result count is read in Transient message queues are a one-pass message queue service that starts processing messages when Start() is called. Any subsequent Start() calls while the service is running is ignored. The transient service will continue to run until all messages have been processed after which time it will shutdown all processing until Start() is called again. Serialize object to buffer serializable object array of serializable objects Deserialize buffer to object byte array to deserialize customize the client serializer Provides thread-safe pooling of redis client connections. Allows load-balancing of master-write and read-slave hosts, ideal for 1 master and multiple replicated read slaves. For interoperabilty GetCacheClient() and GetReadOnlyCacheClient() return an ICacheClient wrapper around the redis manager which has the affect of calling GetClient() for all write operations and GetReadOnlyClient() for the read ones. This works well for master-slave replication scenarios where you have 1 master that replicates to multiple read slaves. Hosts can be an IP Address or Hostname in the format: host[:port] e.g. 127.0.0.1:6379 default is: localhost:6379 The write hosts. The read hosts. The config. Returns a Read/Write client (The default) using the hosts defined in ReadWriteHosts Called within a lock Returns a ReadOnly client using the hosts defined in ReadOnlyHosts. Called within a lock Disposes the read only client. The client. Disposes the write client. The client. Gets or sets object key prefix. Manage a client acquired from the PooledRedisClientManager Dispose method will release the client back to the pool. wrap the acquired client release the wrapped client back to the pool access the wrapped client Provide the default factory implementation for creating a RedisClient that can be mocked and used by different 'Redis Client Managers' Factory to create SerializingRedisClient objects Wrap the common redis set operations under a ICollection[string] interface. Wrap the common redis set operations under a ICollection[string] interface. Creates a Redis MQ Server that processes each message on its own background thread. i.e. if you register 3 handlers it will create 7 background threads: - 1 listening to the Redis MQ Subscription, getting notified of each new message - 3x1 Normal InQ for each message handler - 3x1 PriorityQ for each message handler When RedisMqServer Starts it creates a background thread subscribed to the Redis MQ Topic that listens for new incoming messages. It also starts 2 background threads for each message type: - 1 for processing the services Priority Queue and 1 processing the services normal Inbox Queue. Priority Queue's can be enabled on a message-per-message basis by specifying types in the OnlyEnablePriortyQueuesForTypes property. The DisableAllPriorityQueues property disables all Queues. The Start/Stop methods are idempotent i.e. It's safe to call them repeatedly on multiple threads and the Redis MQ Server will only have Started or Stopped once. Execute global transformation or custom logic before a request is processed. Must be thread-safe. Execute global transformation or custom logic on the response. Must be thread-safe. Execute global error handler logic. Must be thread-safe. If you only want to enable priority queue handlers (and threads) for specific msg types Don't listen on any Priority Queues BasicRedisClientManager for ICacheClient For more interoperabilty I'm also implementing the ICacheClient on this cache client manager which has the affect of calling GetCacheClient() for all write operations and GetReadOnlyCacheClient() for the read ones. This works well for master-slave replication scenarios where you have 1 master that replicates to multiple read slaves. Provides thread-safe retrievel of redis clients since each client is a new one. Allows the configuration of different ReadWrite and ReadOnly hosts Hosts can be an IP Address or Hostname in the format: host[:port] e.g. 127.0.0.1:6379 default is: localhost:6379 The write hosts. The read hosts. Returns a Read/Write client (The default) using the hosts defined in ReadWriteHosts Returns a ReadOnly client using the hosts defined in ReadOnlyHosts. Gets or sets object key prefix. This class manages a read lock for a local readers/writer lock, using the Resource Acquisition Is Initialization pattern RAII initialization RAII disposal A complete redis command, with method to send command, receive response, and run callback on success or failure pop numProcessed items from queue and unlock queue for work item id that dequeued items are associated with A dequeued work item has been processed. When all of the dequeued items have been processed, all items will be popped from the queue,and the queue unlocked for the work item id that the dequeued items are associated with Update first unprocessed item with new work item. pop remaining items that were returned by dequeue, and unlock queue indicate that an item has been processed by the caller Update first unprocessed work item Provides a redis connection pool that can be sharded logical name An arbitrary weight relative to other nodes logical name An arbitrary weight relative to other nodes redis nodes Provides sharding of redis client connections. uses consistent hashing to distribute keys across connection pools maps a key to a redis connection pool key to map a redis connection pool simple distributed work item queue Queue incoming messages Dequeue next batch of work items for processing. After this method is called, no other work items with same id will be available for dequeuing until PostDequeue is called KeyValuePair: key is work item id, and value is list of dequeued items. Courtesy of @marcgravell http://code.google.com/p/protobuf-net/source/browse/trunk/protobuf-net/BufferPool.cs Provide the factory implementation for creating a RedisCacheClient that can be mocked and used by different 'Redis Client Managers' Creates an MQ Host that processes all messages on a single background thread. i.e. If you register 3 handlers it will only create 1 background thread. The same background thread that listens to the Redis MQ Subscription for new messages also cycles through each registered handler processing all pending messages one-at-a-time: first in the message PriorityQ, then in the normal message InQ. The Start/Stop methods are idempotent i.e. It's safe to call them repeatedly on multiple threads and the Redis MQ Host will only have Started/Stopped once. Inject your own Reply Client Factory to handle custom Message.ReplyTo urls.