Hi If you have a system not knowing about generated json then caching would be broken (we should limit its size) but in practise you generate always the same structure either using mapping or fixed schema in the generation process so keys are hardcoded or almost. In this case caching is good.
Caching values could be efficient for ints but not for string, date etc...since it will likely change very often. Romain Manni-Bucau Twitter: @rmannibucau Blog: http://rmannibucau.wordpress.com/ LinkedIn: http://fr.linkedin.com/in/rmannibucau Github: https://github.com/rmannibucau 2014-07-26 13:08 GMT+02:00 Hendrik Dev <[email protected]>: > Hi, > > just looking into JsonGeneratorImpl. > What does "we cache key only since they are generally fixed" mean? > How to fix them "generally"? > > > // we cache key only since they are generally fixed > > private String key(final String name) { > > if (name == null) { > > return NULL_KEY; > > } > > String k = cache.get(name); > > if (k == null) { > > k = '"' + Strings.escape(name) + "\":"; > > cache.putIfAbsent(name, k); > > } > > return k; > > } > > Thanks > Hendrik > > -- > Hendrik Saly (salyh, hendrikdev22) > @hendrikdev22 > PGP: 0x22D7F6EC >
