Interface ReferenceCache

  • All Known Implementing Classes:
    NoopReferenceCache

    public interface ReferenceCache
    The simple interface needed to battle object proliferation when many objects of a type with low cardinality are created. The idea is that you still create the object, but rather than hanging on to it, you pass it through the cache, which may replace your object with a reference to a previously-created object.
    • Method Detail

      • getSharedReference

        <T> T getSharedReference​(T object)
        Get a shared reference to an object. The contract here is that the returned object is an instance of the same class and compares equal to the passed object.
        Parameters:
        object - An object to which you'd like to
        Returns:
        Shared reference to the object.