Caches usually have more management logic than a map, which are nothing else but a more or less simple datastructure.
Some concepts, JCaches may implement
- Expiration: Entries may expire and get removed from the cache after a certain period of time or since last use
- Eviction: elements get removed from the cache if space is limited. There can be different eviction strategies .e. LRU, FIFO, ...
- Distribution: i.e. in a cluster, while Maps are local to a JVM
- Persistence: Elements in the cache can be persistent and present after restart, contents of a Map are just lost
- More Memory: Cache implementations may use more memory than the JVM Heap provides, using a technique called BigMemory where objects are serialized into a separately allocated bytebuffer. This JVM-external memory is managed by the OS (paging) and not the JVM
- option to store keys and values either by value or by reference (in maps you to handle this yourself)
- option to apply security
Some of these some are more general concepts of JCache, some are specific implementation details of cache providers