do not mix the radios

This commit is contained in:
Petitminion 2023-06-06 15:23:33 +02:00
parent 8197271d56
commit df8fc43323
1 changed files with 3 additions and 7 deletions

View File

@ -80,18 +80,14 @@ class SessionRadio(SimpleRadio):
def get_choices(self, **kwargs): def get_choices(self, **kwargs):
kwargs.update(self.get_queryset_kwargs()) kwargs.update(self.get_queryset_kwargs())
if self.session and cache.get( if self.session and cache.get(f"radioqueryset{self.session.id}"):
f"radioqueryset{self.__class__.__name__}{self.session.session_key}"
):
logger.info("Using redis cache for radio generation") logger.info("Using redis cache for radio generation")
queryset = cache.get( queryset = cache.get(f"radioqueryset{self.session.id}")
f"radioqueryset{self.__class__.__name__}{self.session.session_key}"
)
elif self.session: elif self.session:
queryset = self.get_queryset(**kwargs) queryset = self.get_queryset(**kwargs)
logger.info("Setting redis cache for radio generation") logger.info("Setting redis cache for radio generation")
cache.set( cache.set(
f"radioqueryset{self.__class__.__name__}{self.session.session_key}", f"radioqueryset{self.session.id}",
queryset, queryset,
3600, 3600,
) )