Hi devs
http://jira.xwiki.org/browse/XWIKI-13623
I would like to discuss the suggested solution, before I start implementing
it:
*I suggest the following solution:*
Introducing a nested DocumentLoader class which loads the document calling
the basestore loadXWikiDoc in a synchronized getDocOrLoad method. The
DocumentLoader objects gets instantiated in the cacheStore on a cache miss.
It then gets stored in a ConcurrentHashMap using the same key which is used
for the document cache (DocumentReference including language). Using
putIfAbsent to insert the DocumentLoader and calling the synchronized load
method on the object in the map solves the memory visibility issue and
moreover ensures that the same XWikiDocument is not loaded multiple times
concurrently from the database. It is still possible to load different
documents in parallel. A DocumentLoader will load the XWikiDocument only
once and the returns the identical document object on any following call of
the synchronized getDocOrLoad method.
WDYT?
Kind Regards,
Fabian