The approach is ok, but the drawback is that is it not simple to enhance the solution later - no nice interface.
But possible with every JavaEE server without any migration effort as it is standard JavaEE.
Another solution depends a bit on the server you use.
WildFly (community): you might use the internal infinispan subsystem and use is in a HashMap manner. You can simple use it local to start with and change the configuration to clustered (replicated or distributes) if the cache grow and you need more memory to cache it.
JBoss EAP (Enterprise Product): Here you can't use the Infinispan subsystem, technical it is possible but it is not supported. You need to use the additional JBossDataGrid (JDG) which is based on infinispan.
Here you have more options, same as above use the cache in the same JVM local or dist/repl. Or on a different instance with remote access to the cache - often fast enough but you have one remote access - but the JVM is complete separated from the server and can be started maintained different. Also the server and cache did not affect each others memory.
For other vendors you can use the JDG approach (or Infinispan as OpenSource) also.