Sets the max size of the cache to maxSize. If the new maxSize is smaller than the previous value, the cache would be trimmed.