Class StatsNamedContainer<V>

    • Constructor Detail

      • StatsNamedContainer

        public StatsNamedContainer​(int capacity,
                                   int concurrencyLevel)
        Creates a bounded container - based on BoundedConcurrentHashMap
      • StatsNamedContainer

        public StatsNamedContainer()
        Creates an unbounded container - based on ConcurrentHashMap
    • Method Detail

      • clear

        public void clear()
      • keysAsArray

        public String[] keysAsArray()
        This method is inherently racy and expensive. Only use on non-hot paths, and only to get a recent snapshot.
        all keys in string form.
      • getOrCompute

        public @Nullable V getOrCompute​(String key,
                                        Function<String,​V> function)
        Similar semantics as you'd get by invoking ConcurrentMap.computeIfAbsent(Object, Function), but we check for the key existence first. This is technically a redundant check, but it has been shown to perform better when the key existing is very likely, as in our case. Most notably, the ConcurrentHashMap implementation might block other accesses for the sake of making sure the function is invoked at most once: we don't need this guarantee, and prefer to reduce risk of blocking.
      • get

        public @Nullable V get​(String key)