本文整理汇总了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
示例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
示例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)
示例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
示例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
示例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
示例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
示例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)