Requirements

Algorithm 

var image;

if (isCachingAllowed() && isCachingEnabled()) {
   var cache = cacheProvider.getCache()
   var key = hash(macro.source)
   if (!cache.contains(key)) {
      var renderedImage = render()
      cache.put(key, renderedImage)
   }
   image = cache.get(key)
} else {
   image = render()
}


Cache Storage

How to configure/specify the cache as macro parameter?

{plantuml:cache=<empty>|none|attachment|fs|server|...)

<empty>  → could be the default cache storage e.g. in memory cache