I am writing a macro that performs a relatively expensive calculation
to generate content for display (a PNG image) based on user input. The
basic macro works fine, but I'd like to cache the generated content to
save recalculating it when I don't need to.
My idea is that I generate a SHA1 digest of the macro content, and
persistently cache the output generated for that input. I'm thinking
of using an LRU cache to avoid keeping massive amounts of data that'll
never get used again. The question I have is where I can put the cache
so that it is saved with the page, and I can access and update it from
the macro code. I suspect that the answer is to attach an object to
the page somehow, but I've been looking round the documentation and
can't find any examples of how I might do this (TBH, I'm struggling to
find my way round the documentation, so it may be that I've missed
something obvious - if so, then by all means point me to the right
place :-))
As the object is a PNG image, I'm currently base64-encoding it, and
using a data URL to display it. But if it's possible to cache the data
in such a way that the raw data is (or can be made) directly
addressible via a URL, that would be even better.
Can anyone help?
Thanks,
Paul.