python类REDIS_HOST的实例源码

utils.py 文件源码 项目:socialhome 作者: jaywink 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def get_redis_connection():
    return redis.StrictRedis(
        host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=settings.REDIS_DB, password=settings.REDIS_PASSWORD,
    )
set_config.py 文件源码 项目:mass-ipv4-whois 作者: marklit 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def handle(self, *args, **options):
        if not options['coordinator-private-ip']:
            raise CommandError('Coordinator IP needs to be an IP address')

        coord_ip = options['coordinator-private-ip'].strip()

        redis_con = redis.StrictRedis(host=settings.REDIS_HOST,
                                      port=settings.REDIS_PORT,
                                      db=settings.REDIS_DB)
        redis_con.set('KAFKA_HOST',
                      '%s:9092' % coord_ip)
        redis_con.set('COORDINATOR_ENDPOINT',
                      'http://%s:8000/coordinator/' % coord_ip)
get_ips_from_coordinator.py 文件源码 项目:mass-ipv4-whois 作者: marklit 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def in_known_cidr_block(ip_address):
    redis_con = redis.StrictRedis(host=settings.REDIS_HOST,
                                  port=settings.REDIS_PORT,
                                  db=settings.REDIS_DB)
    cidrs = redis_con.get('cidrs')

    if not cidrs or not len(cidrs):
        return False

    return len(netaddr.all_matching_cidrs(ip_address, cidrs.split(','))) > 0
collect_whois.py 文件源码 项目:mass-ipv4-whois 作者: marklit 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def save_to_redis(cidrs):
    try:
        redis_con = redis.StrictRedis(host=settings.REDIS_HOST,
                                      port=settings.REDIS_PORT,
                                      db=settings.REDIS_DB)
        redis_con.set('cidrs', ','.join(list(cidrs)))
    except Exception as exc:
        print exc
config.py 文件源码 项目:mass-ipv4-whois 作者: marklit 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def get_config(item_name):
    try:
        redis_con = redis.StrictRedis(host=settings.REDIS_HOST,
                                      port=settings.REDIS_PORT,
                                      db=settings.REDIS_DB)
        value = redis_con.get(item_name)
    except Exception as exc:
        print exc
        return None

    if value and len(value):
        return value

    return None
redis_op.py 文件源码 项目:onedrop 作者: seraphln 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def __init__(self, host=settings.REDIS_HOST, port=settings.REDIS_PORT):
        self.host = host
        self.port = port
        self.redis_db = self.open_connection()
redis_store.py 文件源码 项目:freesound-datasets 作者: MTG 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def __init__(self, verbose=False):
        self.r = redis.StrictRedis(host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=0)
        self.verbose = verbose
response_aggregator.py 文件源码 项目:ac-mediator 作者: AudioCommons 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def __init__(self):
        self.r = redis.StrictRedis(host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=0)
views.py 文件源码 项目:TLChatServer 作者: tbl00c 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def generate_token_for_user(uid):
    token = hashlib.md5(str(int(time.time() * 1000) + random.randint(10000000, 99999999))).hexdigest()
    r = redis.Redis(host=settings.REDIS_HOST, db=settings.REDIS_USER_TOKEN_DB)
    r.set(uid, token)
    return token

#test
views.py 文件源码 项目:TLChatServer 作者: tbl00c 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def getToken(request):
    uid = request.GET.get('uid')
    r = redis.Redis(host=settings.REDIS_HOST, db=settings.REDIS_USER_TOKEN_DB)
    token = r.get(uid)
    if token is not None:
        return HttpResponse(token)
    else:
        return HttpResponse(u'????token,?token???')
myredis.py 文件源码 项目:myadmmin 作者: luohaifenglight 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __init__(self, **kwargs):
        host = settings.REDIS_HOST
        port = int(settings.REDIS_PORT)
        password = settings.REDIS_PASSWORD
        redis.Redis.__init__(self, host=host, port=port, password=password)


问题


面经


文章

微信
公众号

扫码关注公众号