I am trying to build in-memory cache (using a ConcurrentHashMap
in Java 8).The key value pair would be a json string and the result of a complex operation on that string.
The objective is to not do the complex operation everytime and do it only when the json string changes.
Is there a way I can uniquely represent this string as the value of any of the json keys can change within the application at any time.
I have looked up the hashCode()
method but saw the shortcomings of it.
Right now am trying to see if the MD5 representation of the string would serve as a good key for the JSON string.
If anyone has already faced such a situation, can you please provide your inputs?