Python django.conf.settings 模块,REDIS_DB 实例源码

我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用django.conf.settings.REDIS_DB

项目:socialhome    作者:jaywink    | 项目源码 | 文件源码
def get_redis_connection():
    return redis.StrictRedis(
        host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=settings.REDIS_DB, password=settings.REDIS_PASSWORD,
    )
项目:mass-ipv4-whois    作者:marklit    | 项目源码 | 文件源码
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)
项目:mass-ipv4-whois    作者:marklit    | 项目源码 | 文件源码
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
项目:mass-ipv4-whois    作者:marklit    | 项目源码 | 文件源码
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
项目:mass-ipv4-whois    作者:marklit    | 项目源码 | 文件源码
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