Skip to content

A few small issues #1

@theodorzoulias

Description

@theodorzoulias

I would like to report some issues with the FastCache<TKey, TValue> class, after inspecting briefly the source code.

  1. The internal TtlValue is a class. It could be a struct (more lightweight, less pressure on the garbage collector).
  2. It's possible for the _EvictExpired callback to be invoked in an overlapping manner, if the cache contains many keys and the cleanupJobInterval is very small.
  3. The FastCache<TKey, TValue> is not disposable, so there is no way to stop the timer. The timer will keep ticking until the class is garbage collected.
  4. The FastCache.GetOrAdd does not use the ConcurrentDictionary.GetOrAdd overload that has a TArg generic argument, and so it results in an allocation of a closure on each invocation.
  5. The full functionality of the underlying ConcurrentDictionary<TKey, TValue> is not available. For example the FastCache<TKey, TValue> exposes a void Remove(TKey key) method, and not a bool TryRemove (TKey key, out TValue value) method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions