Skip to content

Document IDisposable implementation of ICacheEntry #7702

Open
@MaxKot

Description

@MaxKot

Help us make content visible

I was looking for details on how to use IMemoryCache and looked specifically into reference documentation entries:

Describe the new article

ICacheEntry implements IDisposable interface but its usage seems different from the other implementations of IDisposable. As can be seen in a comment here, Dispose method appears to be committing the new value to the cache and should not be called if the value to cache can not be created.

The documentation states that ICacheEntry implements IDisposable, but it does not provide any details as to how Dispose method should be implemented and what it should do. The only section showing CreateEntry usage in the tutorial on in-memory caching seems to be not following the guidance in the comment in MemoryCacheExtensions. Discussion here indicates that the IDisposable interface on the ICacheEntry is confusing.

I believe the expected behavior of ICacheEntry implementations should be documented in the Remarks section of ICacheEntry implementation and the right way to use the returned object should be documented in the Remarks section of IMemoryCache.CreateEntry documentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions