Skip to content

Commit

Permalink
refactor(channel_models): Avoid instantiating a new Redis instance ea…
Browse files Browse the repository at this point in the history
…ch time it's needed
  • Loading branch information
elisa-a-v committed Nov 14, 2024
1 parent 25d5f23 commit 523b160
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bc/channel/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

logger = logging.getLogger(__name__)

r = make_redis_interface("CACHE")


class Group(AbstractDateTimeModel):
name = models.CharField(
Expand Down Expand Up @@ -166,7 +168,6 @@ def validate_access_token(self):
"""
if self.service not in self.CHANNELS_TO_REFRESH:
return
r = make_redis_interface("CACHE")
lock_key = self._get_refresh_lock_key()
lock = r.lock(lock_key, sleep=1, timeout=60)
blocking_timeout = 60
Expand Down

0 comments on commit 523b160

Please sign in to comment.