Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add RedisCacheHandler #747

Merged

Conversation

ooyamatakehisa
Copy link
Contributor

@ooyamatakehisa ooyamatakehisa commented Nov 22, 2021

I used redis for token caching in my project, so I contribute this.
This may be useful when using multiple servers.
I'm not sure if I should include redis-py library to dependency of this project because redis library is not directly necessary for main functions of spotipy and only necessary for RedisCacheHandler.
May I have your help?

@stephanebruckert
Copy link
Member

Thanks for that.

Looks like you will have to add the redis package in https://github.com/plamere/spotipy/blob/master/setup.py

Please also update the changelog

@stephanebruckert stephanebruckert merged commit 7d23fc3 into spotipy-dev:master Nov 22, 2021
def get_cached_token(self):
token_info = None
try:
token_info = json.loads(self.redis.get('token_info'))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't self.redis.get('token_info') be None if the value hasn't yet been stored in Redis and then json.loads(None) throw an exception?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Findus23
You're right. I'm sorry for that. I'll fix it.

IdmFoundInHim pushed a commit to IdmFoundInHim/spotipy that referenced this pull request Dec 23, 2021
* add RedisCacheHandler

* add the explanation for customized chache handlers

* update the dependency and chengelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants