Closed stonstad closed 2 years ago
Thank you for reporting,
We will look at this to set the Size
now
Best Regards,
Jon
Jon, can you share what the default cache policy is? Is the cache expired by duration, or weight? i.e. how long is each entry stored?
@JonathanMagnan I'm testing version .82 and this is a question that we are wondering about (above). When an item is entered into the cache, what is the duration or weight used so that we can understand how long the cache is populated? Thanks.
Hello @stonstad ,
A full answer will be provided later today as a new version will be released for this issue and which will change the current answer.
Hello @stonstad ,
The v4.0.83 has been released.
Can you share what the default cache policy is
The default cache policy had no option at all before.
Here is the current new cache policy introduced with the fix for this issue:
new MemoryCacheEntryOptions() { Size = 1 }
So only the Size is set to fix the fix issue when someone specifies a SizeLimit
Since the v4.0.83, it is now possible to change the cache policy using the MemoryCacheEntryOptionsFactory
options such as:
EvalManager.DefaultContext.MemoryCacheEntryOptionsFactory = () => new MemoryCacheEntryOptions() { Size = 2 };
// or for a specific context
var context = new EvalContext();
context.MemoryCacheEntryOptionsFactory = () => new MemoryCacheEntryOptions() { Size = 2 };
You are not limited to the Size
option, you can specify any option.
Let me know if that fixes correctly this issue.
Best Regards,
Jon
Perfect, thank you! Please feel free to close this issue.
EvalManager.Cache = new MemoryCache(new MemoryCacheOptions() { SizeLimit = 100 }); Eval.Execute(...)
// System.InvalidOperationException: 'Cache entry must specify a value for Size when SizeLimit is set.'