Fix issues with memory overhead of writing String objects to cache

String objects have an overhead that is twice the size of the byte array
used to create the String plus the normal overhead for writing an entry
to the cache.