ensure cache is setup

This commit is contained in:
Izalia Mae 2024-02-22 13:44:58 -05:00
parent 61014f791d
commit 097a53a539
2 changed files with 10 additions and 1 deletions

View file

@ -61,9 +61,12 @@ class Application(web.Application):
self['database'] = get_database(self.config)
self['client'] = HttpClient()
self['cache'] = get_cache(self)
self['cache'].setup()
self['push_queue'] = multiprocessing.Queue()
self['workers'] = []
self.cache.setup()
self.on_response_prepare.append(handle_access_log)
self.on_cleanup.append(handle_cleanup)

View file

@ -231,7 +231,7 @@ class SqlCache(Cache):
def setup(self) -> None:
if self._db.connected:
if self._db and self._db.connected:
return
self._db = get_database(self.app.config)
@ -243,6 +243,9 @@ class SqlCache(Cache):
def close(self) -> None:
if not self._db:
return
self._db.disconnect()
self._db = None
@ -351,5 +354,8 @@ class RedisCache(Cache):
def close(self) -> None:
if not self._rd:
return
self._rd.close()
self._rd = None