Connection

class ssdb.connection.Connection(host='127.0.0.1', port=8888, socket_timeout=None, socket_connect_timeout=None, socket_keepalive=False, socket_keepalive_options=None, retry_on_timeout=False, encoding='utf-8', encoding_errors='strict', decode_responses=False, parser_class=<class 'ssdb.connection.PythonParser'>, socket_read_size=65536)

Manages TCP communication to and from a SSDB server

>>> from ssdb.connection import Connection
>>> conn = Connection(host='localhost', port=8888)
class ssdb.connection.ConnectionPool(connection_class=<class 'ssdb.connection.Connection'>, max_connections=None, **connection_kwargs)

Generic connection pool.

>>> from ssdb.client import SSDB
>>> client = SSDB(connection_pool=ConnectionPool())

If max_connections is set, then this objectraises ssdb.ConnectionError when the pool’s limit is reached. By default, TCP connections are created connection_class is specified. Any additionan keyword arguments are passed to the constructor of connection_class.

class ssdb.connection.BlockingConnectionPool(max_connections=50, timeout=20, connection_class=<class 'ssdb.connection.Connection'>, queue_class=<class Queue.LifoQueue>, **connection_kwargs)

Thread-safe blocking connection pool:

>>> from ssdb.client import SSDB
>>> client = SSDB(connection_pool=BlockingConnectionPool())

It performs the same function as default :py:class: ~ssdb.connection.ConnectionPool implementation, in that, it maintains a pool of reusable connections that can be shared by multiple ssdb clients (safely across threads if required).

The difference is that, in the event that a client tries to get a connection from the pool when all of connections are in use, rather than raising a :py:class: ~ssdb.exceptions.ConnectionError (as the default :py:class: ~ssdb.connection.ConnectionPool implementation does), it makes the client wait (“blocks”) for a specified number of seconds until a connection becomes available/].

Use max_connections to increase / decrease the pool size:

>>> pool = BlockingConnectionPool(max_connections=10)

Use timeout to tell it either how many seconds to wait for a connection to become available, or to block forever:

>>> #Block forever.
>>> pool = BlockingConnectionPool(timeout=None)
>>> #Raise a ``ConnectionError`` after five seconds if a connection is not
>>> #available
>>> pool = BlockingConnectionPool(timeout=5)