Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Small perf wins inside MemoryCache #29

@ilmax

Description

@ilmax

Hi, I was looking at the caching code and I found some points which can be enhanced to avoid creating unnecessary objects. I'm referring to the class MemoryCache, the private field _entries can be a Dictionary<string, CacheEntry> instead of anIDictionary<string, CacheEntry> (since it's private and it's always initialized to a Dictionary<string, CacheEntry>) thus saving some unnecessary memory allocation when iterating over Keys and Values. Also the RemoveEntries method could be changed to accept a List instead of IEnumerable<CacheEntry> (since it's a private method always called with an instance of List<CacheEntry>) saving 1 object allocation when iterating over the list of entries. This change will also be consistent with the method ExpirePriorityBucket which already accept generic lists parameters.

It's not a huge improvement, but it's a fairly simple one at least IMHO.

Max.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions