[Play 2.6 Java] Question about cache


I’ve to store in cache a String Key and an Integer as an HashMap.
I don’t understand reading the documentation how to do that.

I would something like:

cache.put(“string”, Integer)

Is it possible? What is the best way?

(Patrick Li) #2

Are you talking about this documentation?

You do cache.set(“key”, “value”) and cache.get(“key”).


I had read the documentation, but I can put in the cache CompletionStage object:
CompletionStage<Done> result = cache.set("item.key", frontPageNews);

I cannot cache an Integer object or a String. If I can, how can I retrieve it?