aiocogeo icon indicating copy to clipboard operation
aiocogeo copied to clipboard

Caching merged range requests

Open geospatial-jeff opened this issue 4 years ago • 1 comments

Ref #23

I think there are a few options which could work:

  • Cache individual tiles after the ranged request. This has the benefit of caching the tile regardless of how it was requested (merged vs. unmerged), but adds complexity because we need to check if all of the tiles encapsulated by a specific merged request are cached before doing the request, skipping the merged request and pulling tiles directly from the cache if this is the case.
  • Cache the range request itself, using start/end as the cache key. This is easier to implement but wont cache the same tile across merged and unmerged requests. Another downside is we will only get a cache hit if the exact same range request is performed (ex. if you have two ranges A->D and B->D there will not be a cache hit even though 75% of the imagery is the same between the two requests).
  • Another solution is to cache with some sort of range key so we never request the same byte from the image more than once. This would of course be useful for every range request we perform and would be implemented on the lower-level Filesystem which is a nice design pattern, but I don't think aiocache has support for this.

There is also an argument to be made that choosing a caching stragegy which works across both merged/unmerged requests since (I think?) most users would be exclusively using either merged or un-merged range requests.

geospatial-jeff avatar May 29 '20 05:05 geospatial-jeff

  • but I don't think aiocache has support for this

A redis specific implementation is creating a sorted set specific to each image where each member of the set is a range we've already request. Then using mget to query the sorted set. Aiocache supports passing raw commands to the underlying cache client so this is possible, but we lose compatibility with other backends.

geospatial-jeff avatar May 29 '20 05:05 geospatial-jeff