As of Infinispan 7, Cache.size() returns the total size of the cluster-wide cache space. This method should use cache.getAdvancedCache().withFlags(Flag.CACHE_MODE_LOCAL, Flag.SKIP_CACHE_LOAD).size() to return just the in-memory entries.