Skip to content

Caching mapped instances

zerounix edited this page Apr 16, 2014 · 1 revision

Nomin by default caches mapped instances. It allows to improve performance in case of frequently repeating values to be mapped. Also caching mapped objects serves as a cycle detection mechanism to prevent infinite loop in case of bidirectional references.

Caching can be disabled. Actually this is required in rare cases. For example you would like to create a new object instance each time you call NominMapper.map(...) instead of getting a cached one. Also there is an interesting case when disabling cache is useful, please refer org.nomin.functional.MappingCasesTest.

To enable or disable caching just call the corresponding method on org.nomin.NominMapper as follows:

nominMapper.enableCache();
// or
nominMapper.disableCache();
Clone this wiki locally