-
Notifications
You must be signed in to change notification settings - Fork 37
Use private instance of MemoryCache and impose size limit #132
Conversation
|
||
void Set(string key, IResponseCacheEntry entry, TimeSpan validFor); | ||
Task SetAsync(string key, IResponseCacheEntry entry, TimeSpan validFor); | ||
void Set(string key, IResponseCacheEntry entry, TimeSpan validFor, long size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking into refactoring the helpers to the interface does not change.
IResponseCachingPolicyProvider policyProvider, | ||
IResponseCachingKeyProvider keyProvider) | ||
: this( | ||
next, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, we can add the MemoryResponseCache to DI but have it resolve ResponseCachingOptions to figure out the size.
{ | ||
/// <summary> | ||
/// The size limit for the response cache middleware in bytes. The default is set to 100 MB. | ||
/// </summary> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we have ResponseCachingOptions extend MemoryCacheOptions so other options can be set?
// Body | ||
if (cachedResponse.Body != null) | ||
{ | ||
size += cachedResponse.Body.Length * sizeof(char); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bytes, not chars.
context.CachedResponseValidFor, | ||
EstimateCachedResponseSize(context.CachedResponse)); | ||
} | ||
catch (OverflowException) { } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't bother, we'll run out of RAM first.
bb3867c
to
2614ab0
Compare
🆙📅 |
2614ab0
to
f125329
Compare
Addresses #127 Still need to add some tests.