opendatakosovo / open-arbk

GNU General Public License v3.0
2 stars 2 forks source link

Implement Flask-Cache #91

Closed dafinaolluri closed 7 years ago

georgeslabreche commented 7 years ago

@dafinaolluri please include in the description the instructions I provided in the e-mail so that it can be further discussed here.

dafinaolluri commented 7 years ago

Description

Tell the system that when it queries the data that is should cache the result for X minutes. During those X minutes, when other users makes the same request (in this case, loads the same page/visualization) then the results will be retrieved from the cache rather than with a direct query to the database.

We are going to keep the implementation simple and use Flask-Cache: https://pythonhosted.org/Flask-Cache/

The Cache Type will be set to simple (SimpleCache). This is not ideal for production environment and doesn’t scale, but it is good enough for our immediate needs. Just for your information, a real production ready environment would implement Flask-Cache with a dedicated cache server that uses caching software like memcached or Redis.

georgeslabreche commented 7 years ago

@KosovareS how was this tested? Because every time I load the data visualization page it takes time to reload the visualization instead of loading immediately from cache. I don't think this is working.

KosovareS commented 7 years ago

@georgeslabreche I tested this on the Map page and it worked

partini commented 7 years ago

@georgeslabreche @KosovareS It should be a memory problem because we tested it locally and it was working perfectly, we also tested on server and it works for short periods of time but once the RAM is full it drops the cache items. There is an option called CACHE_THRESHOLD that you can configure to keep more items in the cache but that would again not work because the server RAM is constantly at 7-10 MB free and it drops cache items to not crash the server.

georgeslabreche commented 7 years ago

@partini @KosovareS increase RAM and test again.

partini commented 7 years ago

@georgeslabreche Ram increased.

KosovareS commented 7 years ago

@partini @diamanthaxhimusa this is still not working