47 questions
127
votes
13
answers
146k
views
How to clear MemoryCache?
I have created a cache using the MemoryCache class. I add some items to it but when I need to reload the cache I want to clear it first. What is the quickest way to do this? Should I loop through all ...
31
votes
2
answers
19k
views
.Net Core MemoryCache PostEvictionCallback not working properly
I have set cache items with sliding expiration in a Microsoft.Extensions.Caching.Memory.MemoryCache.
I want to trigger a callback everytime a cache item expires, but callback isn't triggered until I ...
45
votes
7
answers
33k
views
C volatile variables and Cache Memory
Cache is controlled by cache hardware transparently to processor, so if we use volatile variables in C program, how is it guaranteed that my program reads data each time from the actual memory address ...
77
votes
3
answers
35k
views
Using multiple instances of MemoryCache
I'd like to add caching capabilities to my application using the System.Runtime.Caching namespace, and would probably want to use caching in several places and in different contexts.
To do so, I want ...
47
votes
4
answers
49k
views
MemoryCache AbsoluteExpiration acting strange
I'm trying to use a MemoryCache in .net 4.5 to keep track of and automatically update various items, but it seems like no matter what I set as an AbsoluteExpiration it will always only expire in 15 ...
6
votes
1
answer
8k
views
Volatile and cache behaviour
I read post
C volatile variables and Cache Memory
But i am confused.
Question:
whether OS will take care itself OR
programmer has to write program in such a way that variable should not ...
58
votes
2
answers
43k
views
Is MemoryCache scope session or application wide?
I'm using MemoryCache in ASP.NET and it is working well. I have an object that is cached for an hour to prevent fresh pulls of data from the repository.
I can see the caching working in debug, but ...
32
votes
1
answer
8k
views
Where are .NET 4.0 MemoryCache performance counters?
Where are .NET 4.0 MemoryCache performance counters?
I am looking for their name and I can't find any.
Thank you,
7
votes
3
answers
4k
views
Stop Reentrancy on MemoryCache Calls
The app needs to load data and cache it for a period of time. I would expect that if multiple parts of the app want to access the same cache key at the same time, the cache should be smart enough to ...
40
votes
2
answers
29k
views
What do the size settings for MemoryCache mean?
In a controller class, I have
using Microsoft.Extensions.Caching.Memory;
private IMemoryCache _cache;
private readonly MemoryCacheEntryOptions CacheEntryOptions = new MemoryCacheEntryOptions()
....
13
votes
3
answers
15k
views
Asp.Net Core: Use memory cache outside controller
In ASP.NET Core its very easy to access your memory cache from a controller
In your startup you add:
public void ConfigureServices(IServiceCollection services)
{
services....
6
votes
1
answer
12k
views
Memory Cache in web api
I was looking for Caching in my web api where i can use output of one api method(that changes once in 12hrs) for subsequesnt calls and then i found this solution on SO,but i am having a difficulty in ...
5
votes
3
answers
7k
views
How to implement ListView caching in Android
I have a ListView which contains a large set of data.
At the first time, I load all the data from a Webservice.
Now I want to cache that data so that, if I'm to open that page again, I can fetch ...
4
votes
2
answers
5k
views
.Net 4 Memory Cache class and user Session
The new class MemoryCache in .Net 4.0 appears to act just like asp.net caching. My questions are:
Is MemoryCache equivalent to storing an object/value in for a user in Session Cache, but not in the ...
36
votes
4
answers
92k
views
Memory Cache in dotnet core
I am trying to write a class to handle Memory cache in a .net core class library. If I use not the core then I could write
using System.Runtime.Caching;
using System.Collections.Concurrent;
...
15
votes
1
answer
12k
views
.net MemoryCache - notify on item removed
I'm using a .net Memory Cache with .NET 4.0 and c#, I want my application to be notified when an item is removed (so I can write that it has been removed to a log file or notify the UI, that the item ...
10
votes
4
answers
24k
views
How to clear MemoryCache in ASP.NET Core?
How to correctly clear IMemoryCache from ASP.NET Core?
I believe this class is missing Clear method, but anyway how to deal with it? In my project I'm caching DocumentRepository's methods for 24 ...
8
votes
1
answer
5k
views
Load EhCache diskstore content into memory
As said in EhCache documentation:
In practice this means that persistent in-memory cache will start up with all of its elements on disk. [...] So, the Ehcache design does not load them all into ...
7
votes
1
answer
1k
views
What, exactly, do MemoryCache's memory limits mean?
System.Runtime.Caching.MemoryCache is a class in the .NET Framework (version 4+) that caches objects in-memory, using strings as keys. More than System.Collections.Generic.Dictionary<string, ...
5
votes
2
answers
3k
views
Using MemoryCache with HostFileChangeMonitor init to a directory gets ArgumentOutOfRangeException
I am using MemoryCache from System.Runtime.Caching of .NET 4 and I wish to invalidate the cache entry when a directory changes.
HostFileChangeMonitor is supposed to handle both files and directories ...
2
votes
0
answers
1k
views
Self-renewing MemoryCache
I have implemented a cache that renews the containing values when they expire.
My code is this:
class MyCache
{
private static readonly MemoryCache Cache = MemoryCache.Default;
private ...
1
vote
1
answer
3k
views
A second operation started on this context before a previous operation completed
I have a project with asp.net core and entity framework core, for performance reasons I use MemoryCache. ForumQueryManager class is for querying forum data. This class for data uses the CacheManager ...
0
votes
0
answers
416
views
How can I use both DiskLruCache(DiskCache) and LruCache(MemoryCache)?
I'm developing Image Loader using both cache.
and here is my logic.
1st, start get the images on the disk cache (when app starting)
2nd, check the memory cache. if it is, load from Cache memory.
...
0
votes
3
answers
2k
views
MVC Net Core Pass MemoryCache to All Controllers
I am building a online shop website. I want to display ProductCategory as a Sidebar (short list categories, Eg Clothes, Electronics, Furniture, Books, etc).
At the end, I want to send around ...