Class ConcurrentUnboundedStringCache<STRING_LIKE_TYPE extends CharSequence>

java.lang.Object
io.deephaven.base.string.cache.ConcurrentUnboundedStringCache<STRING_LIKE_TYPE>
All Implemented Interfaces:
StringCache<STRING_LIKE_TYPE>

public class ConcurrentUnboundedStringCache<STRING_LIKE_TYPE extends CharSequence> extends Object implements StringCache<STRING_LIKE_TYPE>
A very limited interface is specified, in order to decouple typeAdapter pooling and related concerns from the cache itself. StringCompatibles or Strings used as keys (or values) when probing/populating the cache are allowed to use their own hashCode() implementation. This is dangerous, because we rely on our key implementation to hash CharSequences identically to a String of the same characters. An assertion in the value factory should catch any cases where the built-in assumption breaks down, but we've deemed that unnecessary at this time. Specify "debug" in the constructor if you need this check. String.hashCode()'s implementation has been stable since JDK 1.2, and is specified in the JavaDocs. This implementation is thread-safe, and lock-free except for the insertion of new cached Strings on a cache miss. StringCompatible implementation thread-safety is a separate concern.
  • Constructor Details

    • ConcurrentUnboundedStringCache

      public ConcurrentUnboundedStringCache(@NotNull @NotNull StringCacheTypeAdapter<STRING_LIKE_TYPE> typeAdapter, int initialCapacity, boolean debug)
      Parameters:
      typeAdapter - The type adapter for this cache
      initialCapacity - Initial capacity of the map backing this cache
      debug - Whether constructed Strings should be checked for consistency against the StringCompatible used
  • Method Details