Skip to content

Add caching layer for TIFF strips#52

Closed
pritgit28 wants to merge 1 commit into
geocaml:mainfrom
pritgit28:cache
Closed

Add caching layer for TIFF strips#52
pritgit28 wants to merge 1 commit into
geocaml:mainfrom
pritgit28:cache

Conversation

@pritgit28
Copy link
Copy Markdown
Contributor

@patricoferris Hi! This pr includes comments about ideas and design for a caching layer using a hash map for O(1) lookups. If I were to implement the cache layer, this is the layout I was able to come up with. Kindly look through the comments and guide me on what needs changes or additions, and I will incorporate that into my final implementation.

@pritgit28 pritgit28 force-pushed the cache branch 2 times, most recently from ce9577b to def5d62 Compare November 3, 2025 09:25
@patricoferris
Copy link
Copy Markdown
Contributor

Thanks for the ideas here @pritgit28. I think something like this or what @mdales proposed in #31 would be good. I think to make our lives easier it would be good for us to internally hide the implementation details of the cache from ourselves and expose some interface to the cache, that way if we refactor the cache it will be much easier (I'm thinking about when it comes to adding write support).

Concretely I think we need a cache.ml(i) file. Off the top of my head something like:

type t
(** A cache for raw tiff data *)

type key = int

val add : t -> key -> Cstruct.t -> unit

val find : t -> key -> Cstruct.t option

val reset : t -> unit

We could then implement that under-the-hood as a hashtable, or an association list, or something more optimised/featureful later. What do you think?

@pritgit28
Copy link
Copy Markdown
Contributor Author

@patricoferris I’m always blown away after your walkthrough. My idea was based entirely on #31 . I will keep the implementation modular as guided. I just have doubts about what must be cached, should we cache after decompression or the compressed data. I couldn’t pick up which one from the comment under type t which says “a cache for raw tiff data”.

@pritgit28 pritgit28 closed this Dec 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants