Skip to content

Commit 304aa30

Browse files
committed
add disk caching
1 parent 78c544e commit 304aa30

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

helpers/twitch_utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ async def scan_user(self, user: StreamerConnection, users: dict):
4949
async def get_videos(self, user: TwitchUser, vod_depth: int):
5050
key = f"{user.display_name.lower()}.vods"
5151

52-
if self.cache:
52+
if self.cache is not None:
5353
videos = self.cache.get(key=key, default=[])
5454
if videos:
5555
return videos
@@ -59,13 +59,13 @@ async def get_videos(self, user: TwitchUser, vod_depth: int):
5959
sort=SortMethod.TIME, video_type=VideoType.ARCHIVE):
6060
if v and v.title and "@" in v.title:
6161
videos.append(v)
62-
if self.cache:
62+
if self.cache is not None:
6363
self.cache.set(key=key, expire=self.config.cache_vodlist_expiry, value=videos)
6464
return videos
6565

6666
async def get_user_by_name(self, username: str):
6767
key = f"{username}.user"
68-
if self.cache:
68+
if self.cache is not None:
6969
user = self.cache.get(key=key, default=None)
7070
if user:
7171
return user
@@ -76,7 +76,7 @@ async def get_user_by_name(self, username: str):
7676
self.logger.warning(f"Exception with username {username}, {e}")
7777
user = None
7878
if user and user.display_name.lower() == username.lower():
79-
if self.cache:
79+
if self.cache is not None:
8080
self.cache.set(key=key, expire=self.config.cache_user_expiry, value=user)
8181
return user
8282
return None

0 commit comments

Comments
 (0)