Closed joeflack4 closed 3 years ago
This issue seems similar to: #33
My problem was that I am still new at docker and I needed to connect to this kind of URL:
REDIS_URL=redis://DOCKER_REDIS_SERVICE_NAME:6379
In my docker-compose.yml, I named my redis service ccdh-redis
, so I needed it to look like this:
REDIS_URL=redis://ccdh-redis:6379
Description
Sorry for the very apt title. I'm working on this codebase: https://github.com/joeflack4/ccdh-terminology-service/tree/feature_cache
I have an
app.py
file where I'm importingFastApiRedisCache()
and setting it up instartup()
.I'm adding
@cache()
to several routers, one of which is inmodels.py
. I'm using this endpoint as a test case to make sure things re working.There's not much there at the moment, but it returns something. Here's what you can get from that endpoint as seen on our production server: https://terminology.ccdh.io/models/ https://terminology.ccdh.io/docs#/CRDC-H%20and%20CRDC%20Node%20Models/get_models
However when I check server logs or the Redis monitor, I'm not seeing anything being cached at this or any other endpoint.
To see all the changes I've made to my codebase to implement this feature, perhaps looking at this diff in my draft pull request might help: https://github.com/cancerDHC/ccdh-terminology-service/pull/53/files
Note that this setup uses docker.
Where I've checked
1. Redis monitor
I don't see anything coming up as I'm checking my routes on localhost.
2. Server logs
I can't see any of the tell-tale signs of caching as per the
fastapi-redis-cache
documentation. I do see that the endpoints are getting hit. But they're not caching.What I've tried
I tried Checking that the 'redis_url' is actually getting set. In
app.py
, I set upFastApiRedisCache()
as followsI then entered the docker container and ran python and just checked to make sure that
get_settings().redis_url
existed and was correct.Possible solutions
This actually may be a problem on my docker config end. I'm investigating that now, trying out at least these 3 things:
I'm not sure what else to try. Maybe there is something wrong with my setup in my Python code? Maybe something wrong with my docker setup?