Skip to content

Commit

Permalink
Simplify check for existing token (#765)
Browse files Browse the repository at this point in the history
* Simplify check for existing token in RedisCacheHandler

* Update CHANGELOG.md
  • Loading branch information
ENT8R committed Jan 3, 2022
1 parent 08411b9 commit 9a627e8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Added `RedisCacheHandler`, a cache handler that stores the token info in Redis.
* Changed URI handling in `client.Spotify._get_id()` to remove qureies if provided by error.
* Added a new parameter to `RedisCacheHandler` to allow custom keys (instead of the default `token_info` key)
* Simplify check for existing token in `RedisCacheHandler`

## [2.19.0] - 2021-08-12

Expand Down
5 changes: 3 additions & 2 deletions spotipy/cache_handler.py
Expand Up @@ -166,8 +166,9 @@ def __init__(self, redis, key=None):
def get_cached_token(self):
token_info = None
try:
if self.redis.exists(self.key):
token_info = json.loads(self.redis.get(self.key))
token_info = self.redis.get(self.key)
if token_info:
return json.loads(token_info)
except RedisError as e:
logger.warning('Error getting token from cache: ' + str(e))

Expand Down

0 comments on commit 9a627e8

Please sign in to comment.