Simplify check for existing token (#765)

* Simplify check for existing token in RedisCacheHandler

* Update CHANGELOG.md
This commit is contained in:
ENT8R 2022-01-03 19:33:13 +01:00 committed by GitHub
parent 08411b9031
commit 9a627e88f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -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

View File

@ -166,8 +166,9 @@ class RedisCacheHandler(CacheHandler):
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))