Implemented string size caching into the callbacks

This way our callback is not called twice for string values as it will
simply store the size locally each time toString() is getting called.