当前位置: 首页>>代码示例>>Python>>正文


Python Redis.from_url方法代码示例

本文整理汇总了Python中redis.Redis.from_url方法的典型用法代码示例。如果您正苦于以下问题:Python Redis.from_url方法的具体用法?Python Redis.from_url怎么用?Python Redis.from_url使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在redis.Redis的用法示例。


在下文中一共展示了Redis.from_url方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_app

# 需要导入模块: from redis import Redis [as 别名]
# 或者: from redis.Redis import from_url [as 别名]
def create_app():

    # setting the static_url_path to blank serves static files from the web root
    app = Flask(__name__, static_url_path='')
    app.config.from_object(__name__)

    Swagger(app, template_file='definitions.yaml')

    app.redis = Redis.from_url(app.config['REDIS_URL'])
    app.task_queue = rq.Queue('recon-tasks', connection=app.redis)

    @app.after_request
    def disable_cache(response):
        response.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate'
        return response

    @app.route('/')
    def index():
        return render_template('index.html', workspaces=recon._get_workspaces())

    from recon.core.web.api import resources
    app.register_blueprint(resources)

    return app 
开发者ID:lanmaster53,项目名称:recon-ng,代码行数:26,代码来源:__init__.py

示例2: test_isdisjoint

# 需要导入模块: from redis import Redis [as 别名]
# 或者: from redis.Redis import from_url [as 别名]
def test_isdisjoint(self):
        a = RedisSet('abc')
        b = RedisSet('cde')
        assert not a.isdisjoint(b)
        c = RedisSet('def')
        assert a.isdisjoint(c)

        other_url = 'redis://127.0.0.1:6379/'
        other_redis = Redis.from_url(other_url, socket_timeout=1)
        b = RedisSet('cde', redis=other_redis)
        assert not a.isdisjoint(b)
        c = RedisSet('def', redis=other_redis)
        assert a.isdisjoint(c)

        d = {'c', 'd', 'e'}
        assert not a.isdisjoint(d)
        e = {'d', 'e', 'f'}
        assert a.isdisjoint(e) 
开发者ID:brainix,项目名称:pottery,代码行数:20,代码来源:test_set.py

示例3: __init__

# 需要导入模块: from redis import Redis [as 别名]
# 或者: from redis.Redis import from_url [as 别名]
def __init__(self, *args, **kwargs):
        """
        args and kwargs are forwarded to redis.from_url
        """
        self.redis = Redis.from_url(*args, decode_responses=True, **kwargs) 
开发者ID:steinitzu,项目名称:celery-singleton,代码行数:7,代码来源:redis.py

示例4: __init__

# 需要导入模块: from redis import Redis [as 别名]
# 或者: from redis.Redis import from_url [as 别名]
def __init__(self, config):
        """
        Use redis as the streaming client.

        Configuration keys:
            REDIS_URL
            REDIS_CHANNEL
            REDIS_SLEEP_TIME

        """
        self.channel = config['REDIS_CHANNEL']
        self.sleep_time = config.get('REDIS_SLEEP_TIME', 0.1)
        self.redis = Redis.from_url(config['REDIS_URL'])
        self.receiver_thread: Optional[PubSubWorkerThread] = None 
开发者ID:microsoft,项目名称:agogosml,代码行数:16,代码来源:redis_streaming_client.py

示例5: __init__

# 需要导入模块: from redis import Redis [as 别名]
# 或者: from redis.Redis import from_url [as 别名]
def __init__(self):
        self.redis = Redis.from_url(settings.REDIS_URL) 
开发者ID:gnosis,项目名称:safe-relay-service,代码行数:4,代码来源:redis_repository.py

示例6: get_database

# 需要导入模块: from redis import Redis [as 别名]
# 或者: from redis.Redis import from_url [as 别名]
def get_database(config, master=True):
    if config['sentinel']:
        sentinal = Sentinel(config['sentinel'], socket_timeout=0.1,
                            password=config['redis_password'], db=config['redis_database'])
        if master:
            return sentinal.master_for(config['sentinel_cluster_name'])
        else:
            return sentinal.slave_for(config['sentinel_cluster_name'])
    else:
        return Redis.from_url(config['redis']) 
开发者ID:openprocurement,项目名称:openprocurement.auction,代码行数:12,代码来源:utils.py

示例7: __init__

# 需要导入模块: from redis import Redis [as 别名]
# 或者: from redis.Redis import from_url [as 别名]
def __init__(self):
        self.redis = Redis.from_url(self.URL) 
开发者ID:alephdata,项目名称:followthemoney,代码行数:4,代码来源:cache.py

示例8: init_db

# 需要导入模块: from redis import Redis [as 别名]
# 或者: from redis.Redis import from_url [as 别名]
def init_db(self, url=None):
        self.redis = Redis.from_url(url or self.redis_url) 
开发者ID:qmppz,项目名称:igotolibrary,代码行数:4,代码来源:RedisHelper.py

示例9: __init__

# 需要导入模块: from redis import Redis [as 别名]
# 或者: from redis.Redis import from_url [as 别名]
def __init__(self):
        # redis 操作客户端
        self._client = pyRedis.from_url(PERSISTENCE['url'])
        # 可搜索项
        self._index_keys = ('anonymity', 'protocol') 
开发者ID:gavin66,项目名称:proxy_list,代码行数:7,代码来源:redis_impl.py

示例10: main

# 需要导入模块: from redis import Redis [as 别名]
# 或者: from redis.Redis import from_url [as 别名]
def main():
    # Bootstrap the worker assets
    bugbug_http.boot.boot_worker()

    # Provide queue names to listen to as arguments to this script,
    # similar to rq worker
    redis_url = os.environ.get("REDIS_URL", "redis://localhost/0")
    redis_conn = Redis.from_url(redis_url)
    with Connection(connection=redis_conn):
        qs = sys.argv[1:] or ["default"]

        w = Worker(qs)
        w.work() 
开发者ID:mozilla,项目名称:bugbug,代码行数:15,代码来源:worker.py

示例11: cache_redis_connection_url

# 需要导入模块: from redis import Redis [as 别名]
# 或者: from redis.Redis import from_url [as 别名]
def cache_redis_connection_url(self, value: Optional[str]) -> None:
        self._cache_redis_connection_url = value
        if value is not None:
            self._cache_redis = Redis.from_url(value) 
开发者ID:rominf,项目名称:profanity-filter,代码行数:6,代码来源:profanity_filter.py

示例12: restart

# 需要导入模块: from redis import Redis [as 别名]
# 或者: from redis.Redis import from_url [as 别名]
def restart(access_key):
    """Restarts a failed job"""

    account_id = Account.authorize(request.values.get('api_key'))

    jobs = Job.query.filter_by(access_key = access_key)
    job = jobs.first()
    
    if job == None or not account_id or not account_id == job.account_id:
        return jsonify(api_error('API_UNAUTHORIZED')), 401

    if not job.failed:
        return jsonify(api_error('JOBS_NOT_RESTARTABLE')), 400

    if job.data_deleted:
        return jsonify(api_error('JOBS_DATA_DELETED')), 400

    ip = fix_ip(request.headers.get('x-forwarded-for', request.remote_addr))

    job.ip_address = ip
    job.failed = 0
    job.fail_code = 0
    job.status = 'queued'
    db.session.commit()
    redis_conn = Redis.from_url(os.environ.get('REDIS_URI'))
    q = Queue(job.account.get_priority(), connection=redis_conn)
    q.enqueue_call(func=send_fax, args=(job.id,), timeout=3600)

    return jsonify(job.public_data()) 
开发者ID:lyonbros,项目名称:faxrobot,代码行数:31,代码来源:jobs.py

示例13: charge

# 需要导入模块: from redis import Redis [as 别名]
# 或者: from redis.Redis import from_url [as 别名]
def charge():
    if request.values.get("admin_token") != os.environ.get("ADMIN_TOKEN"):
        return jsonify(api_error("ADMIN_BAD_ADMIN_TOKEN")), 401

    redis_conn = Redis.from_url(current_app.config['REDIS_URI'])
    q = Queue('default', connection=redis_conn)
    q.enqueue_call(func=charge_subscribers,  timeout=300)

    return jsonify({"kthx": "bai"}) 
开发者ID:lyonbros,项目名称:faxrobot,代码行数:11,代码来源:accounts.py

示例14: __init__

# 需要导入模块: from redis import Redis [as 别名]
# 或者: from redis.Redis import from_url [as 别名]
def __init__(self):
        """Create a new Redis instance when a new object for this class is created.
        """
        self.redis = Redis.from_url(CACHE_URL)
        logger.info('Connected to Redis at ' + CACHE_URL) 
开发者ID:Jonarzz,项目名称:DotaResponsesRedditBot,代码行数:7,代码来源:redis_cache.py

示例15: __init__

# 需要导入模块: from redis import Redis [as 别名]
# 或者: from redis.Redis import from_url [as 别名]
def __init__(self, queue=None, redis_url=None, queue_name='kaneda'):
        if not Redis:
            raise ImproperlyConfigured('You need to install redis to use the RQ queue.')
        if not Queue:
            raise ImproperlyConfigured('You need to install rq library to use the RQ queue.')
        if queue:
            if not isinstance(queue, Queue):
                raise ImproperlyConfigured('"queue" parameter is not an instance of RQ queue.')
            self.queue = queue
        elif redis_url:
            self.queue = Queue(queue_name, connection=Redis.from_url(redis_url))
        else:
            self.queue = Queue(queue_name, connection=Redis()) 
开发者ID:APSL,项目名称:kaneda,代码行数:15,代码来源:rq.py


注:本文中的redis.Redis.from_url方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。