本文整理匯總了Python中django.conf.settings.REDIS_HOST屬性的典型用法代碼示例。如果您正苦於以下問題:Python settings.REDIS_HOST屬性的具體用法?Python settings.REDIS_HOST怎麽用?Python settings.REDIS_HOST使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類django.conf.settings
的用法示例。
在下文中一共展示了settings.REDIS_HOST屬性的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import REDIS_HOST [as 別名]
def get(self, request, *args, **kwargs):
connect = redis.StrictRedis(
host=settings.REDIS_HOST,
port=settings.REDIS_PORT,
db=settings.REDIS_SPACE,
password=settings.REDIS_PASSWD
)
week_list = ['Won', 'Tue', 'Wed', 'Thur', 'Fri', 'Sat', 'Sun']
TEMP = connect.hgetall('WORK',)
WORK = []
for key in week_list:
WORK.append({
'time': str(key, encoding='utf-8'),
'執行次數': TEMP[key]
})
return Response(
{'title': '一周內工單執行','dataset': WORK} or {}, status.HTTP_200_OK
)
示例2: invalidate_view_cache_for_tenant_and_cache_key
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import REDIS_HOST [as 別名]
def invalidate_view_cache_for_tenant_and_cache_key(schema_name, cache_key_prefix=None):
"""Invalidate our view cache for a specific tenant and source type.
If cache_key_prefix is None, all views will be invalidated.
"""
cache = caches["default"]
if isinstance(cache, RedisCache):
cache = Redis(host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=settings.REDIS_DB)
all_keys = cache.keys("*")
all_keys = [key.decode("utf-8") for key in all_keys]
elif isinstance(cache, LocMemCache):
all_keys = list(locmem._caches.get(settings.TEST_CACHE_LOCATION).keys())
all_keys = [key.split(":", 2)[-1] for key in all_keys]
else:
msg = "Using an unsupported caching backend!"
raise KokuCacheError(msg)
all_keys = all_keys if all_keys is not None else []
if cache_key_prefix:
keys_to_invalidate = [key for key in all_keys if (schema_name in key and cache_key_prefix in key)]
else:
# Invalidate all cached views for the tenant
keys_to_invalidate = [key for key in all_keys if schema_name in key]
for key in keys_to_invalidate:
cache.delete(key)
msg = f"Invalidated request cache for\n\ttenant: {schema_name}\n\tcache_key_prefix: {cache_key_prefix}"
LOG.info(msg)
示例3: municipality_data
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import REDIS_HOST [as 別名]
def municipality_data(request):
# r = redis.StrictRedis(host=settings.REDIS_HOST, port=6379, db=3)
# data = r.hgetall("municipality")
data = generate_municipality_data()
return Response(data.values())
示例4: __init__
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import REDIS_HOST [as 別名]
def __init__(self):
self._pool = redis.ConnectionPool(host=settings.REDIS_HOST, port=settings.REDIS_PORT,
decode_responses=True, db=settings.MAP_CACHE_DB,
password=settings.REDIS_PASSWORD)
self.client = redis.Redis(connection_pool=self._pool)
示例5: get_redis_client
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import REDIS_HOST [as 別名]
def get_redis_client() -> redis.StrictRedis:
return redis.StrictRedis(host=settings.REDIS_HOST, port=settings.REDIS_PORT,
password=settings.REDIS_PASSWORD, db=0)
示例6: __init__
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import REDIS_HOST [as 別名]
def __init__(self, verbose=False):
self.r = redis.StrictRedis(host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=0)
self.verbose = verbose
示例7: connect
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import REDIS_HOST [as 別名]
def connect(self):
cc = lambda *args: protocol.ClientCreator(reactor, *args)
self.redis_sub = RedisDispatch(settings.REDIS_HOST, settings.REDIS_PORT)
redis_factory = RedisServiceRegisteringFactory(self)
reactor.connectTCP(settings.REDIS_HOST, settings.REDIS_PORT, redis_factory)
yield redis_factory.deferred
示例8: __init__
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import REDIS_HOST [as 別名]
def __init__(self):
if self.__kerberos_has_ticket() is False:
self.__kerberos_init()
if api.isdone('finalize') is False:
api.bootstrap_with_global_options(context='api')
api.finalize()
api.Backend.rpcclient.connect()
self.redis = redis.StrictRedis(host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=settings.REDIS_DB, password=settings.REDIS_PASSWORD)
示例9: __init__
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import REDIS_HOST [as 別名]
def __init__(self, thread_id, name, experiment, component_id, max_results, cache_results):
threading.Thread.__init__(self)
self.threadID = thread_id
self.name = name
self.experiment = experiment
self.comp_id = component_id
self.result = {}
self.max_results = max_results
self.cache_results = cache_results
print "Submitting topology to storm. End component", self.comp_id
exp = Experiment.objects.get(pk=self.experiment)
graph = exp.workflow.graph_data
graph_data = {}
print graph
tmp = graph.split(',')
for elem in tmp:
first_node = elem.split(":")[0]
second_node = elem.split(":")[1]
if second_node in graph_data:
depend_nodes = graph_data[second_node]
depend_nodes.add(first_node)
else:
graph_data[second_node] = set()
graph_data[second_node].add(first_node)
topological_graph = toposort_flatten(graph_data)
print "Graph after topological sort", topological_graph
message = {
'exp_id': self.experiment, 'result': self.comp_id,
'graph': topological_graph, 'components': defaultdict()}
for data in topological_graph:
component_id = int(data)
comp = Component.objects.get(pk=component_id)
if comp.operation_type.function_type == 'Create':
if comp.operation_type.function_arg == 'Table':
filename = comp.operation_type.function_subtype_arg
input_data = read_csv(filename)
message['input'] = {}
for elem in list(input_data.columns):
message['input'][elem] = list(input_data[elem])
message['cols'] = list(input_data.columns)
# message['input'] = input_data.to_dict()
serialized_obj = serializers.serialize('json', [comp.operation_type, ])
print "Component_id", component_id, " ", comp.operation_type
message['components'][data] = serialized_obj
print "Message ", message
r = redis.StrictRedis(host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=0)
self.pubsub = r.pubsub(ignore_subscribe_messages=True)
self.pubsub.subscribe("Exp " + str(self.experiment))
ret = r.publish('workflow', json.dumps(message))
print "return", ret