Question

I'm looking at Alfresco's logs while fetching documents and I can see that each time I try to retrieve the same doc (same ID), a GET request is made to the remote repository.

I ran a test where I explicitly call session.getDefaultContext().setCacheEnabled(true) before calling session.getObject(id) several times. It seems the cache is ignored as the GET command is issued each time.

Do you think there may be other properties that should be set on the session that I'm missing? Or maybe some xml configuration for Alfresco?

Thanks

Was it helpful?

Solution

It depends on the document ID you are using to retrieve a document. Alfresco CMIS document IDs look like this (note the ";v.v" part):

workspace://SpacesStore/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx;v.v

Alfresco also accepts document IDs that look like node IDs (note the missing ";v.v" part) to retrieve documents, but always returns the format above.

workspace://SpacesStore/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

The OpenCMIS cache uses the first document ID format (with ";v.v" part) as cache key. If you are using the second format, you will never get a cache hit and the client has to ask the repository again for the document data.

OTHER TIPS

seems to work for getObject, but for actually retrieving the content, the cache is not used:

Document document = (Document)session.getObject(id); document.getContentStream().getStream();

the last line triggers a GET to alfresco_root/folder/content/doc_name?id=id;version

can the client cache be actually used for storing the doc content?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top