[Play 2.6 Java] Question about cache


#1

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)
cache.get(“string”)
cache.delete(“string”)

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”).


#3

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?