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

connecting to an SSL StrictRedis instance for caching #137

Open
RedCraig opened this issue Mar 11, 2016 · 4 comments
Open

connecting to an SSL StrictRedis instance for caching #137

RedCraig opened this issue Mar 11, 2016 · 4 comments

Comments

@RedCraig
Copy link

This isn't an issue per-se, just something that took me a while to figure out - and I wanted to check the way I'm doing this is OK.

I want to connect to an instance of the microsofts redis cache in azure.
They require an ssl connection, example uses StrictRedis connection:

import redis 
r = redis.StrictRedis(host='.redis.cache.windows.net', port=6380, db=0, password='', ssl=True) 
r.set('foo', 'bar') True 
r.get('foo') b'bar'

I couldn't see how to make this work with the flask-cache redis config keys.

I started digging through the source, flask-cache uses werkzeug RedisCache, whose docs say:
The first argument can be either a string denoting address of the Redis server or an object resembling an instance of a redis.Redis class.

So it's actually possible to create a StrictRedis instance and pass it to flask-caches CACHE_ARGS in the CACHE_REDIS_HOST option.
It works, it just seems a little ...undocumented?
All that said, I don't quite see how to use the Custom Cache Backends described in flask-cache docs here, so perhaps there's a way to do similar there.

Thanks for any help!

@RedCraig RedCraig changed the title connecting to an SSL redis instance connecting to an SSL StrictRedis instance for caching Apr 21, 2016
@barakalon
Copy link

Just stumbled across this as well

@bradwitte
Copy link

Also had this issue with TLS enabled Redis on AWS

@nicholaskuechler
Copy link

@RedCraig How did you make this work? Can you please share your working example code?

@bradwitte
Copy link

Here is what worked for me:

import redis 
r = redis.StrictRedis(host='blahblah', port=6380, db=0, password='mypass', ssl=True) 

CACHE_CONFIG = {
'CACHE_TYPE': 'redis',
'CACHE_REDIS_HOST': r,
}

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

No branches or pull requests

4 participants