How to use the redislite.client.RedisMixin function in redislite

To help you get started, we’ve selected a few redislite examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yahoo / redislite / redislite / client.py View on Github external
with open(self.pidfile) as file_handle:
                pid = int(file_handle.read().strip())
                if pid:  # pragma: no cover
                    try:
                        process = psutil.Process(pid)
                    except psutil.NoSuchProcess:
                        return 0
                    if not process.is_running():
                        return 0
                else:  # pragma: no cover
                    return 0
            return int(pid)
        return 0  # pragma: no cover


class Redis(RedisMixin, redis.Redis):
    """
    This class provides an enhanced version of the :class:`redis.Redis()` class
    that uses an embedded redis-server by default.


    Parameters
    ----------

    dbfilename : str, optional

        The name of the Redis db file to be used.

        This argument is only used if the embedded redis-server is used.

        The value of this argument is provided as the "dbfilename" setting in
        the embedded redis server configuration.  This will result in the
github yahoo / redislite / redislite / client.py View on Github external
)
        else:
            self._create_redis_directory_tree()

            if not self.dbdir:
                self.dbdir = self.redis_dir
                self.settingregistryfile = os.path.join(
                    self.dbdir, self.dbfilename + '.settings'
                )

            self._start_redis()

        kwargs['unix_socket_path'] = self.socket_file
        # noinspection PyArgumentList
        logger.debug('Calling binding with %s, %s', args, kwargs)
        super(RedisMixin, self).__init__(*args, **kwargs)  # pragma: no cover

        logger.debug("Pinging the server to ensure we're connected")
        self._wait_for_server_start()
github yahoo / redislite / redislite / client.py View on Github external
db : string
        The fully qualified filename associated with the redis dbfilename
        configuration setting.  This attribute is read only.

    pid :int
        Pid of the running embedded redis server, this attribute is read
        only.

    start_timeout : float
        Number of seconds to wait for the redis-server process to start
        before generating a RedisLiteServerStartError exception.
    """
    pass


class StrictRedis(RedisMixin, redis.StrictRedis):
    """
    This class provides an enhanced version of the :class:`redis.StrictRedis()`
    class that uses an embedded redis-server by default.


    Example:
        redis_connection = :class:`redislite.StrictRedis('/tmp/redis.db')`


    Notes:
        If the dbfilename argument is not provided each instance will get a
        different redis-server instance.


    Args:
        dbfilename(str):