Open RedCraig opened 8 years ago
Just stumbled across this as well
Also had this issue with TLS enabled Redis on AWS
@RedCraig How did you make this work? Can you please share your working example code?
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,
}
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:
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-cache
sCACHE_ARGS
in theCACHE_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 inflask-cache
docs here, so perhaps there's a way to do similar there.Thanks for any help!