1
0
Fork 0
mirror of synced 2024-05-20 04:22:29 +12:00

Merge branch 'rewrite' of https://github.com/Phxntxm/Bonfire into rewrite

This commit is contained in:
Phxntxm 2017-06-16 20:58:11 -05:00
commit 0a7cfb42b7

View file

@ -29,12 +29,16 @@ class Cache:
self.loop = loop
self.values = [] # The values returned from the database
self.refreshed_time = None
self.loop.create_task(self.check_refresh())
self.loop.create_task(self.refresh_task())
async def refresh(self):
self.values = await self.db.actual_load(self.table)
self.refreshed_time = datetime.now()
async def refresh_task(self):
await self.check_refresh()
await asyncio.sleep(60)
async def check_refresh(self):
if self.refreshed_time is None:
await self.refresh()
@ -43,8 +47,6 @@ class Cache:
if difference.total_seconds() > 300:
await self.refresh()
self.loop.call_later(60, self.check_refresh())
def get(self, key=None, table_filter=None, pluck=None):
"""This simulates the database call, to make it easier to get the data"""
if key is None and table_filter is None: