Skip to content

Add InitialCapacity function to builder #47

Closed
@maypok86

Description

Clarification and motivation

Since otter supports cost-based eviction, we cannot pre-initialize internal structures, but in reality this feature is rarely used, and other users may not be happy because otter allocated more memory than it could. So we would like to add an InitialCapacity function with which users could preallocate otter's internal data structures.

The usage is envisioned like this

c, err := otter.MustBuilder[int, int](size).
    InitialCapacity(size).
    WithTTL(time.Second).
    Build()

Acceptance criteria

  1. The InitialCapacity function is added to the builder.
  2. Implementation tests are written

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions