/** Adds near cache stats. */
  protected void addNearCacheStats(
      LocalMapStatsImpl stats,
      LocalMapOnDemandCalculatedStats onDemandStats,
      MapContainer mapContainer) {
    if (!mapContainer.getMapConfig().isNearCacheEnabled()) {
      return;
    }
    NearCache nearCache = nearCacheProvider.getOrCreateNearCache(mapContainer.getName());
    NearCacheStats nearCacheStats = nearCache.getNearCacheStats();
    long nearCacheHeapCost = mapContainer.getNearCacheSizeEstimator().getSize();

    stats.setNearCacheStats(nearCacheStats);
    onDemandStats.incrementHeapCost(nearCacheHeapCost);
  }
  protected AbstractClientInternalCacheProxy(
      CacheConfig cacheConfig,
      ClientContext clientContext,
      HazelcastClientCacheManager cacheManager) {
    super(cacheConfig, clientContext);
    this.cacheManager = cacheManager;
    this.nearCacheManager = clientContext.getNearCacheManager();
    this.asyncListenerRegistrations =
        new ConcurrentHashMap<CacheEntryListenerConfiguration, String>();
    this.syncListenerRegistrations =
        new ConcurrentHashMap<CacheEntryListenerConfiguration, String>();
    this.syncLocks = new ConcurrentHashMap<Integer, CountDownLatch>();

    initNearCache();

    if (nearCache != null) {
      this.statistics =
          new ClientCacheStatisticsImpl(System.currentTimeMillis(), nearCache.getNearCacheStats());
    } else {
      this.statistics = new ClientCacheStatisticsImpl(System.currentTimeMillis());
    }
    this.statisticsEnabled = cacheConfig.isStatisticsEnabled();
  }