I’m writing some code to access Redis from Java, and as such I need to create a lot of Strings as keys. These keys have a pattern, of course, and I’ll be regenerating the same keys for the same access repeatedly.
I’m considering implementing a cache for the generated keys (based on the DAO parameters), but even given the speed of a cache, I’m wondering if the speedup is worth the complexity.
The keys are comprised of a UUID concatenated with a 3-7 character string. Is StringBuilder slow enough in this scenario to warrant a cache?
Only profiling can tell you for sure, but if you’re caching these you have to have some way to get them from the cache, and that likely will have at least as much overhead as just using StringBuilder.
StringBuilder is used internally when doing things like