Caching geoQueries effectively?

Hey there,

do you guys have any good advice on caching geo queries?

What first came to my mind is the following approach:

Within the geoQuery we need to pass lat+lng so it could make sense to “round” lat+lng so that I will get the same query result for a specific area. I could then put the result into the cache and relate it to a latLng key.

Would this be a good practice or do you suggest another approach?
Besides, is it worth (in terms of performance) to try everything to avoid database queries wherever possible?

Hi Jens,

It sounds quite reasonable - anything that would help you avoid hitting the database will help with performance. Our cache uses memory-based storage, so it is ultra-fast. The only change in your approach I would consider is moving the logic “check in cache, if not, fetch from db and put into cache” into a custom service so all the data transfer from db into cache happens on the server side.

Regards,
Mark

“The only change in your approach I would consider is moving the logic “check in cache, if not, fetch from db and put into cache” into a custom service so all the data transfer from db into cache happens on the server side.”

Sorry for not mentioning it but I’m already doing so.