fastapi-cache2 не кэширует когда много вложенных объектов, возвращает пустой список как исправить? Может есть более адекватные пакеты?
class CityWithoutCountryID(BaseCity):
id: PositiveInt = CityFields.id
name: str = CityFields.name
class CountryWithCities(Country):
cities: Union[List[CityWithoutCountryID], List] = []
class CountriesWithPagination(BaseCountry):
items: Union[List[CountryWithCities], List[Country]] = []
total: PositiveIntWithZero = ForPaginationFields.total
page: PositiveIntWithZero = ForPaginationFields.page
size: PositiveInt = ForPaginationFields.size
CountriesWithPagination он возвращает как:
{
"items": [],
"total": 0,
"page": 0,
"size": 10
}
без декоратора кэширования:
{
"items": [
{
"id": 1,
"name": "Guatemala",
"cities": [
{
"id": 6,
"name": "Josephville"
},
{
"id": 11,
"name": "South Brandon"
}
]
},
{
"id": 2,
"name": "Cayman Islands",
"cities": [
{
"id": 8,
"name": "Lake Benjamin"
}
]
},
{
"id": 3,
"name": "Kiribati",
"cities": [
{
"id": 1,
"name": "Edgarfurt"
}
]
},
{
"id": 4,
"name": "Uganda",
"cities": []
},
{
"id": 5,
"name": "Malaysia",
"cities": []
},
{
"id": 6,
"name": "Christmas Island",
"cities": [
{
"id": 3,
"name": "Gregoryburgh"
},
{
"id": 10,
"name": "Port Timothybury"
}
]
},
{
"id": 7,
"name": "Central African Republic",
"cities": [
{
"id": 4,
"name": "Port Cassandrafurt"
}
]
},
{
"id": 8,
"name": "Denmark",
"cities": []
},
{
"id": 9,
"name": "Cameroon",
"cities": [
{
"id": 5,
"name": "Lake Brianna"
},
{
"id": 7,
"name": "Gonzalezburgh"
},
{
"id": 9,
"name": "Brownfort"
},
{
"id": 12,
"name": "North Margaretview"
}
]
},
{
"id": 10,
"name": "Nigeria",
"cities": [
{
"id": 2,
"name": "Stevensmouth"
}
]
}
],
"total": 13,
"page": 0,
"size": 10
}
с меньшей вложенностью работает как надо