Closed lsetiawan closed 7 years ago
Checkout
Great articles! I think for long term and scalability Redis wins out.
Seems like redis is the right choice. So adding django-redis to requirements.txt should be part of this then eh?
Ah yes, thanks for catching that!
Ok, so it is setup here http://dev-odm2admin.cuahsi.org/ODM2-Admintest/mapdata.html the map loads very quickly :-) How and when is the cache rebuilt?
CACHE_TTL specifies how often the cache should be refreshed. I defaulted to 15 minutes from the example on this link: https://realpython.com/blog/python/caching-in-django-with-redis/
Ok, yes I see, Is there a way to tigger a cache rebuild on saving a sampling feature? I'm looking at the documentation but I haven't found something like that yet.
Flush all method: https://niwinz.github.io/django-redis/latest/#_testing_with_django_redis
I'd assume that will clear the entire cache, which is ok when there is only one thing in the cache, but won't be good when we add more things. Maybe persist and expire can be used https://niwinz.github.io/django-redis/latest/#_expire_persist ?
Still not 100% sure on how to implement all that, but for now the caching for get_features for the map is a good first step, it makes the map loads faster the 2nd time. I think this is safe to merge.
seems like the issue highlighted in the article below could be a potential issue, I'm going to try this on another instance of ODM2 Admin on the same server. Seems like I might just have to set a different KEY_PREFIX
for the cache.
http://chrislaskey.com/blog/342/running-multiple-redis-instances-on-the-same-server/
no, seems fine, probably fine due to different URLs for the get_features page.
@lsetiawan I'll add a release, docker will also need to be updated? or it should work due to requirements.txt being updated?
@miguelcleon Docker will also need to be updated to add Redis-server in the django compose stack. Have you take a look at my other PR's? Maybe those should be merged if they're good before a release to keep the version confusions, I don't want to have many different development happening, starting to get confusing. Thanks
So, just starting to look into this. Why should we use redis instead of the Django native memcached? https://docs.djangoproject.com/en/1.11/topics/cache/