How the cache is stored
Hi, what kind of cache library do you use?
How to solve the problem of multiple keys?
Here is a similar problem:
https://stackoverflow.com/questions/59103206/how-to-cache-an-object-with-multiple-keys-in-c-sharp
The solution is interesting, but it makes the cache constant and can overflow (no expiry date of the item)
Stack Overflow
How to cache an object with multiple keys in C#
I have models that are unique in 2 or more properties. For example, objects of the class Entity are unique both by name and by ID.
public class Entity
{
public int Id { get; set; }
public
15 Replies
Which is better, storage in ram or e.g. redis? The app isn't big, just one server.
https://github.com/dotnetcore/EasyCaching
Anyone using this? Is it better than Microsoft's default?
GitHub
GitHub - dotnetcore/EasyCaching: EasyCaching is an open source cach...
:boom: EasyCaching is an open source caching library that contains basic usages and some advanced usages of caching which can help us to handle caching more easier! - GitHub - dotnetcore/EasyCachin...
most of the time we just use MemoryCache
Cache in-memory in ASP.NET Core
Learn how to cache data in memory in ASP.NET Core.
right?
Yeah, just
services.AddMemoryCache();
then you can inject IMemoryCacheIs it possible to clear the cache?
I used to test it but without a key I had a problem with it. I had to restart the application to clear the cache.
Unsure, never had to clear the whole cache. I guess you could wrap the cache and add a set of keys and clear if needed but feels hacky
You can remove stuff but you need a key as you stated.
Anyone know how to make multiple keys? Apparently it's called a tag
Not sure what you mean
Stack Overflow
How to cache an object with multiple keys in C#
I have models that are unique in 2 or more properties. For example, objects of the class Entity are unique both by name and by ID.
public class Entity
{
public int Id { get; set; }
public
I found a similar problem here.
The point is for one value to have many keys.
in other programming languages this is called tags
Unfortunately, I have searched the documentation and I do not see such an option.
Can you point to this tag concept in other programming languages?
Just looking, can't find it right now.
I saw in node and PHP that there are "tags"
Thanks to this, you can have many keys, for example:
There is a user, has an ID, Name, E-mail, telephone number and full name
You can search for it by ID, Name, E-mail and Phone
e.g.
1 | User | [email protected] | +11 111 111 111 | John | Smith
search by id
1
= John Smith
serch by name User
= John Smith
search by mail [email protected]
= John SmithWell if you are willing to do a linear search you can obviously search for objects by any property. If you want an efficient search there are a variety of options (for instance, keep the data sorted and do a binary search, or build some kind of index) but for something like a dictionary (which is based on hash tables) there is no magic way to do a fast lookup on multiple different properties - that's not how hash tables work.
And MemoryCache uses a dictionary internally