What is the proper way (or ways) to use Objectify 4.0 with the <threadsafe>true</threadsafe> setting in an AppEngine app? The following is in the "Caching" Wiki page, but what else should we be aware of?
The session cache is not thread-safe. You should never share an Objectify instance between threads.
- Also, on a side-note: is there a way to temporarily disable the session cache for our own testing purposes - not involving ofy().clear()?
The default options are:
Ok. Follow-up questions...
Given the following code:
Objectify objectifyInstance = ObjectifyService.factory().begin();
1) The javadoc for begin() indicates:
The default options are:
But the wiki page says the session cache is enabled automatically. Is the javadoc just out-of-date?
- Do NOT begin a transaction.
- Do NOT use a session cache.
- DO use a global cache.
- Use STRONG consistency.
- Apply no deadline to calls.
2) And just to double-check, is the above code the proper way to start a new session (e.g. in a servlet's doPost() method) when running in threadsafe-mode?
3) When using multiple Objectify instances, is there anything (resource-wise) we need to deal with when an instance is about to be discarded (e.g. at the end of a doPost() method)?