예제 #1
0
def get_tile(request, tile_key):
    """ Return Json from redis for tile_key """
    if not checkAccessToken(method='GET', request=request, unsecured=True):
        return HttpResponse('API KEY incorrect', status=401)
    redis = MyCache().redis
    if redis.exists(getRedisPrefix(tile_key)):
        return HttpResponse(redis.get(tile_key))
    return HttpResponseBadRequest(f'{tile_key} key does not exist.')
예제 #2
0
def delete_tile(request, tile_key):
    """ Delete in redis """
    if not checkAccessToken(method='DELETE', request=request, unsecured=True):
        return HttpResponse('API KEY incorrect', status=401)
    redis = MyCache().redis
    if redis.exists(getRedisPrefix(tile_key)):
        redis.delete(tile_key)
        return HttpResponse('Tile\'s data deleted.')
    return HttpResponseBadRequest(f'{tile_key} key does not exist.')
예제 #3
0
def get_tile(request, tile_key):
    httpMessage = ''
    httpStatus_code = 200
    redis = MyCache().redis
    if redis.exists(getRedisPrefix(tile_key)):
        if request.method == 'DELETE':
            redis.delete(tile_key)
            httpMessage = 'Tile\'s data deleted.'
        if request.method == 'GET':
            httpMessage = redis.get(tile_key)
    else:
        httpMessage = f'{tile_key} key does not exist.'
        httpStatus_code = 400
    return httpMessage, httpStatus_code