0
点赞
收藏
分享

微信扫一扫

2.1.ReactOS源码分析ReadFile函数分解

四月天2021 2024-10-30 阅读 21
CACHES = {
    'default': {
        'BACKEND': 'django_redis.cache.RedisCache',
        'LOCATION': 'redis://127.0.0.1:6379/0',
        'OPTIONS': {
            'CLIENT_CLASS': 'django_redis.client.DefaultClient',
            'CONNECTION_POOL_KWARGS':{
                'decode_responses':True
            }
        }
    },
    'sms': {
        'BACKEND': 'django_redis.cache.RedisCache',
        'LOCATION': 'redis://127.0.0.1:6379/1',
        'OPTIONS': {
            'CLIENT_CLASS': 'django_redis.client.DefaultClient',
            'CONNECTION_POOL_KWARGS':{
                'decode_responses':True
            }
        }
    }
}

使用

 from django_redis import get_redis_connection
    # 默认连接配置文件中的库
    redis_conn = get_redis_connection()
    #校验key是否存在
    if not redis_conn.exists(f'activation_{username}'):
        context = {
            'code': 10011,
            'error': '激活用户不存在'
        }
        return JsonResponse(context)
    rand = redis_conn.get(f'activation_{username}')
    code2 = md5(username + rand)
举报

相关推荐

0 条评论