Login  Register

Cacheable Asciidoctor Extension

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options Options
Embed post
Permalink
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Cacheable Asciidoctor Extension

rahmanusta
Hi;

In my custom extensions, i need to cache returned content from extension function for some heavy tasks. If the content inside of block didnt changed, get  last result from cache. I can implement it but I wonder, is there anything built-in in extension system?
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Cacheable Asciidoctor Extension

mojavelinux
Administrator
Not at the moment, though I've had it on my mind for awhile and I filed an issue to address it. Feel free to submit ideas about the API there.


I'm not sure if the cache should be on the runtime or the document. If it's on the runtime, we need to make sure it's protected by the the thread_safe collections.

Currently, you can use the references property (of type Hash) on the document object, though it's not specifically designed to be a generic cache (it could get cleared in certain cases).

-Dan

On Sun, Dec 7, 2014 at 10:43 AM, rahmanusta [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Hi;

In my custom extensions, i need to cache returned content from extension function for some heavy tasks. If the content inside of block didnt changed, get  last result from cache. I can implement it but I wonder, is there anything built-in in extension system?


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Cacheable-Asciidoctor-Extension-tp2512.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Cacheable Asciidoctor Extension

rahmanusta
Thanks Dan, there can be a runtime hashmap as a cache. I did caching in Java with ConcurrentHashMap. I think there can be a Cachable function that marks extension cacheable. There can be a native implementation and others should implement their own implementation also.
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Cacheable Asciidoctor Extension

mojavelinux
Administrator

On Wed, Dec 10, 2014 at 10:57 AM, rahmanusta [via Asciidoctor :: Discussion] <[hidden email]> wrote:
. I think there can be a Cachable function that marks extension cacheable. There can be a native implementation and others should implement their own implementation also.

Oh, in that case, Ruby already supports this. They call memoizing. There's are at least two gems that will handle all the plumbing. 


Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Cacheable Asciidoctor Extension

rahmanusta
Aha, this can be used