:param redis_client: Redis client
        :param db: Redis Database index
        :param port: Redis port
        :return: Redis queue length
426236
def publish_queue_length(self, redis_client, port, db):
        
        for queue in redis_client.smembers('queues'):
            queue_length = redis_client.llen('queue:%s' % queue)
            self.__publish(port, db, queue, queue_length)
456062
def len(self, queue_name):
        
        try:
            stats = self.conn.stats_tube(queue_name)
        except beanstalkc.CommandFailed as err:
            if err[1] == 'NOT_FOUND':
                return 0

            raise

        return stats.get('current-jobs-ready', 0)
1021791
def __get_connection(self) -> redis.Redis:
        

        if self.__redis_use_socket:
            r = redis.from_url(
                'unix://{:s}?db={:d}'.format(
                    self.__redis_host,
                    self.__redis_db
                )
            )
        else:
            r = redis.from_url(
                'redis://{:s}:{:d}/{:d}'.format(
                    self.__redis_host,
                    self.__redis_port,
                    self.__redis_db
                )
            )

        if BlackRed.Settings.REDIS_AUTH is not None:
            r.execute_command('AUTH {:s}'.format(BlackRed.Settings.REDIS_AUTH))
        return r
345568
async def redis(self) -> aioredis.Redis:
        
        # Use thread-safe asyncio Lock because this method without that is not safe
        async with self._connection_lock:
            if self._redis is None:
                self._redis = await aioredis.create_redis_pool((self._host, self._port),
                                                               db=self._db, password=self._password, ssl=self._ssl,
                                                               minsize=1, maxsize=self._pool_size,
                                                               loop=self._loop, **self._kwargs)
        return self._redis
965609
public int getConnectionPoolSize(String host, int port) {
        RequestBuilder req = new RequestBuilder();
        req.host = host;
        req.port = port;
        return _getPoolSize(req);
    }
656845
function RedisBackend(port, hostname, opts)
{
	if(!(this instanceof RedisBackend)){
		return new RedisBackend(port, hostname, opts);
	}

	opts = opts || {};
	port = port || 6379;
	hostname = hostname || 'localhost';

	this.redis = redis.createClient(port, hostname, opts);
	this.publish = redis.createClient(port, hostname, opts);

	this.prefix = opts.prefix + '';

	this.baseKey = baseKey(this.prefix);
}
487287
def dbsize(host=None, port=None, db=None, password=None):
    '''
    
    '''
    server = _connect(host, port, db, password)
    return server.dbsize()
1109267
def filter_connection_params(queue_params):
    
    CONNECTION_PARAMS = ('URL', 'DB', 'USE_REDIS_CACHE',
                         'UNIX_SOCKET_PATH', 'HOST', 'PORT', 'PASSWORD',
                         'SENTINELS', 'MASTER_NAME', 'SOCKET_TIMEOUT',
                         'SSL', 'CONNECTION_KWARGS',)

    #return {p:v for p,v in queue_params.items() if p in CONNECTION_PARAMS}
    # Dict comprehension compatible with python 2.6
    return dict((p,v) for (p,v) in queue_params.items() if p in CONNECTION_PARAMS)
295200
def set_db_row(db, start, size, _bytearray):
    
    client.db_write(db, start, size, _bytearray)
1142770
def write(self, client):
        
        assert(isinstance(self._bytearray, DB))
        assert(self.row_size >= 0)

        db_nr = self._bytearray.db_number
        offset = self.db_offset
        data = self.get_bytearray()[offset:offset+self.row_size]
        db_offset = self.db_offset

        # indicate start of write only area of row!
        if self.row_offset:
            data = data[self.row_offset:]
            db_offset += self.row_offset

        client.db_write(db_nr, db_offset, data)
718858
def init_db_conn(
        connection_name, HOST=None, PORT=None, DB=None, PASSWORD=None):
    
    rpool = redis.ConnectionPool(
        host=HOST, port=PORT, db=DB, password=PASSWORD)
    r = redis.Redis(connection_pool=rpool)
    redis_pool.connections[connection_name] = RedisClient(r)
483274
def as_db_get(self, db_number):
        
        logger.debug("db_get db_number: %s" % db_number)
        _buffer = buffer_type()
        result = self.library.Cli_AsDBGet(self.pointer, db_number,
                                          byref(_buffer),
                                          byref(c_int(buffer_size)))
        check_error(result, context="client")
        return bytearray(_buffer)
269442
def get_connection(name='default', use_strict_redis=False):
    
    from .settings import QUEUES
    return get_redis_connection(QUEUES[name], use_strict_redis)
44391
def parse_client_table(redis_client):
    
    NIL_CLIENT_ID = ray.ObjectID.nil().binary()
    message = redis_client.execute_command("RAY.TABLE_LOOKUP",
                                           ray.gcs_utils.TablePrefix.CLIENT,
                                           "", NIL_CLIENT_ID)

    # Handle the case where no clients are returned. This should only
    # occur potentially immediately after the cluster is started.
    if message is None:
        return []

    node_info = {}
    gcs_entry = ray.gcs_utils.GcsTableEntry.GetRootAsGcsTableEntry(message, 0)

    ordered_client_ids = []

    # Since GCS entries are append-only, we override so that
    # only the latest entries are kept.
    for i in range(gcs_entry.EntriesLength()):
        client = (ray.gcs_utils.ClientTableData.GetRootAsClientTableData(
            gcs_entry.Entries(i), 0))

        resources = {
            decode(client.ResourcesTotalLabel(i)):
            client.ResourcesTotalCapacity(i)
            for i in range(client.ResourcesTotalLabelLength())
        }
        client_id = ray.utils.binary_to_hex(client.ClientId())

        # If this client is being removed, then it must
        # have previously been inserted, and
        # it cannot have previously been removed.
        if not client.IsInsertion():
            assert client_id in node_info, "Client removed not found!"
            assert node_info[client_id]["IsInsertion"], (
                "Unexpected duplicate removal of client.")
        else:
            ordered_client_ids.append(client_id)

        node_info[client_id] = {
            "ClientID": client_id,
            "IsInsertion": client.IsInsertion(),
            "NodeManagerAddress": decode(
                client.NodeManagerAddress(), allow_none=True),
            "NodeManagerPort": client.NodeManagerPort(),
            "ObjectManagerPort": client.ObjectManagerPort(),
            "ObjectStoreSocketName": decode(
                client.ObjectStoreSocketName(), allow_none=True),
            "RayletSocketName": decode(
                client.RayletSocketName(), allow_none=True),
            "Resources": resources
        }
    # NOTE: We return the list comprehension below instead of simply doing
    # 'list(node_info.values())' in order to have the nodes appear in the order
    # that they joined the cluster. Python dictionaries do not preserve
    # insertion order. We could use an OrderedDict, but then we'd have to be
    # sure to only insert a given node a single time (clients that die appear
    # twice in the GCS log).
    return [node_info[client_id] for client_id in ordered_client_ids]
254637
def _determine_slot(self, *args):
        
        if len(args) <= 1:
            raise RedisClusterException("No way to dispatch this command to Redis Cluster. Missing key.")
        command = args[0]

        if command in ['EVAL', 'EVALSHA']:
            numkeys = args[2]
            keys = args[3: 3 + numkeys]
            slots = {self.connection_pool.nodes.keyslot(key) for key in keys}
            if len(slots) != 1:
                raise RedisClusterException("{0} - all keys must map to the same key slot".format(command))
            return slots.pop()

        key = args[1]

        return self.connection_pool.nodes.keyslot(key)
498990
def from_url(url, db=None, **kwargs):
    
    from redis.client import Redis
    return Redis.from_url(url, db, **kwargs)
641196
def size(self):
        

        if self.id.endswith("/"):
            subqueues = self.get_known_subqueues()
            if len(subqueues) == 0:
                return 0
            else:
                with context.connections.redis.pipeline(transaction=False) as pipe:
                    for subqueue in subqueues:
                        pipe.get("queuesize:%s" % subqueue)
                    return [int(size or 0) for size in pipe.execute()]
        else:
            return int(context.connections.redis.get("queuesize:%s" % self.id) or 0)