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


Python StrictRedis.from_url方法代码示例

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


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

示例1: redis

# 需要导入模块: from redis.client import StrictRedis [as 别名]
# 或者: from redis.client.StrictRedis import from_url [as 别名]
def redis(app=None):
    app = app_or_default(app)

    if not hasattr(app, "redbeat_redis") or app.redbeat_redis is None:
        app.redbeat_redis = StrictRedis.from_url(app.conf.REDBEAT_REDIS_URL, decode_responses=True)

    return app.redbeat_redis
开发者ID:sibson,项目名称:redbeat,代码行数:9,代码来源:schedulers.py

示例2: flushdb

# 需要导入模块: from redis.client import StrictRedis [as 别名]
# 或者: from redis.client.StrictRedis import from_url [as 别名]
 def flushdb(self):
     """Destroy every shard's db
     """
     for pool in self.pool_map.values():
         con = StrictRedis.from_url(pool.url, connection_pool=pool)
         self.log.debug("flushing shard member: %s", con)
         con.flushdb()
         del con
开发者ID:nficano,项目名称:jotonce.com,代码行数:10,代码来源:redis_con.py

示例3: __init__

# 需要导入模块: from redis.client import StrictRedis [as 别名]
# 或者: from redis.client.StrictRedis import from_url [as 别名]
 def __init__(self, redis_connection=None, locker=None, *args, **kwargs):
     self.__redis_connection = redis_connection
     if self.__redis_connection is None:
          self.__redis_connection = StrictRedis.from_url(current_app.conf.CELERY_REDIS_SCHEDULER_URL)
     self._schedule = EntryProxy(self.__redis_connection)
     self._locker = locker
     if self._locker is None:
         self._locker = Redlock([current_app.conf.CELERY_REDIS_SCHEDULER_URL])
     super(ChardScheduler, self).__init__(*args, **kwargs)
开发者ID:SPSCommerce,项目名称:swiss-chard,代码行数:11,代码来源:scheduler.py

示例4: get_app

# 需要导入模块: from redis.client import StrictRedis [as 别名]
# 或者: from redis.client.StrictRedis import from_url [as 别名]
def get_app(config=None):
    """
    App factory.

    :param dict config: configuration that can override config
        from `settings.py`
    :return: a new SuperdeskEve app instance
    """
    if config is None:
        config = {}

    config.setdefault('SOURCES', {})
    config['APP_ABSPATH'] = os.path.dirname(os.path.abspath(os.path.dirname(__file__)))

    for key in dir(settings):
        if key.isupper():
            config.setdefault(key, getattr(settings, key))

    media_storage = SuperdeskGridFSMediaStorage
    if config.get('AMAZON_CONTAINER_NAME'):
        from superdesk.storage.amazon.amazon_media_storage import AmazonMediaStorage
        media_storage = AmazonMediaStorage

    app = Eve(
        auth=BearerAuth,
        settings=config,
        data=SuperdeskDataLayer,
        media=media_storage,
        json_encoder=MongoJSONEncoder,
        validator=SuperdeskValidator
    )

    superdesk.app = app
    _set_error_handlers(app)
    app.mail = Mail(app)
    if config.get('REDIS_URL'):
        app.redis = StrictRedis.from_url(config['REDIS_URL'], 0)

    for module_name in app.config['INSTALLED_APPS']:
        app_module = importlib.import_module(module_name)
        try:
            app_module.init_app(app)
        except AttributeError:
            pass

    for resource in config['DOMAIN']:
        app.register_resource(resource, config['DOMAIN'][resource])

    for blueprint in superdesk.BLUEPRINTS:
        prefix = app.api_prefix or None
        app.register_blueprint(blueprint, url_prefix=prefix)

    app.sentry = sentry
    sentry.init_app(app)

    return app
开发者ID:ioanpocol,项目名称:superdesk-content-api,代码行数:58,代码来源:__init__.py

示例5: connection

# 需要导入模块: from redis.client import StrictRedis [as 别名]
# 或者: from redis.client.StrictRedis import from_url [as 别名]
 def connection(self, node_id):
     if not self.__ready:
         return
     shard = self.shard_node(node_id)
     try:
         pool = self.pool_map.get(self.shard_map.get(shard))
         con = StrictRedis.from_url(pool.url, connection_pool=pool)
         yield con
     except Exception:
         self.log.exception("Something blew up in the Redis context "
                            "manager")
         raise
     finally:
         del con
开发者ID:nficano,项目名称:jotonce.com,代码行数:16,代码来源:redis_con.py

示例6: pipeline

# 需要导入模块: from redis.client import StrictRedis [as 别名]
# 或者: from redis.client.StrictRedis import from_url [as 别名]
 def pipeline(self, node_id):
     if not self.__ready:
         return
     shard = self.shard_node(node_id)
     try:
         pool = self.pool_map.get(self.shard_map.get(shard))
         con = StrictRedis.from_url(pool.url, connection_pool=pool)
         with con.pipeline() as pipe:
             try:
                 yield pipe
                 pipe.execute()
             except:
                 self.log.exception("Something blew up inside a pipeline "
                                    "context")
                 pipe.reset()
                 raise
     except Exception:
         self.log.exception("Something blew up in the Redis context "
                            "manager")
         raise
     finally:
         del con
开发者ID:nficano,项目名称:jotonce.com,代码行数:24,代码来源:redis_con.py

示例7: ValidationError

# 需要导入模块: from redis.client import StrictRedis [as 别名]
# 或者: from redis.client.StrictRedis import from_url [as 别名]
try:
    import simplejson as json
except ImportError:
    import json

from celery.beat import Scheduler, ScheduleEntry
from celery.utils.log import get_logger
from celery import current_app
import celery.schedules

from redis.client import StrictRedis

from decoder import DateTimeDecoder, DateTimeEncoder

# share with result backend
rdb = StrictRedis.from_url(current_app.conf.CELERY_REDIS_SCHEDULER_URL)


class ValidationError(Exception):
    pass


class PeriodicTask(object):
    '''represents a periodic task
    '''
    name = None
    task = None

    type_ = None

    interval = None
开发者ID:georgewhewell,项目名称:celerybeatredis,代码行数:33,代码来源:schedulers.py

示例8: range

# 需要导入模块: from redis.client import StrictRedis [as 别名]
# 或者: from redis.client.StrictRedis import from_url [as 别名]
from redis.exceptions import RedisError
from telegram.bot import Bot
from telegram.ext.commandhandler import CommandHandler
from telegram.ext.conversationhandler import ConversationHandler
from telegram.ext.dispatcher import Dispatcher
from telegram.ext.regexhandler import RegexHandler

from epl_bot.helpers import _get_upcoming_matches
from django.conf import settings

from epl_bot.models import Fixture, Bet, Score

logger = logging.getLogger(__name__)

MATCH, REBET, HOSTS, GUESTS = range(4)
redis = StrictRedis.from_url(settings.REDIS_URL)
match_id = ''


def bet(bot, update):
    upcoming = _get_upcoming_matches(0, 10)
    if upcoming:
        try:
            buttons = [[telegram.KeyboardButton(u"{}. {}".format(i, m.bet_text))]
                       for i, m in enumerate(upcoming, start=1)]
            reply_markup = telegram.ReplyKeyboardMarkup(buttons,
                                                        one_time_keyboard=True)
            bot.sendMessage(chat_id=update.message.chat_id,
                            text="Choose a match to bet:",
                            reply_markup=reply_markup)
开发者ID:hesussavas,项目名称:epl_bot,代码行数:32,代码来源:handlers.py


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