Currently doing a blacklist functionality, this is roughly program will receive the highest 50 times per second, each message will have a UserId this parameter, then I according to the UserId to match the blacklist, if do not make any response in the blacklist,
I consider the original design of the blacklist is saved in the database, but always felt that visit too often, plus blacklist consider about million level data, worried that efficiency is not high, so consider using the cache, the new list with synchronization to each client machine,
Thought is similar to server-side redis, customers also need to install the server too much trouble,
I also checked some related information, just don't know what can ensure enough about 50 times per second match and can guarantee the execution efficiency of the method,
Have any good solution? Also hope you glad,
CodePudding user response:
MemoryCachehttps://docs.microsoft.com/zh-cn/dotnet/api/system.runtime.caching.memorycache
To add a System. The Runtime. Caching references,
CodePudding user response:
Casual, memorycache can,Blacklist data is not too much, even if you put List< directly; T> It doesn't matter,
CodePudding user response:
System start to read database blacklist, deposit to the List for each linq match the List, the List without this List is added to the List and written to the databaseCodePudding user response:
Don't ask, direct do,A lot of programmers is like all sorts of entanglements, the good the bad, always like to say more than do less
For this requirement, you said we don't ask directly to do it, you only need to ensure that abstract, Microsoft has given the abstract the Exits as a cache, Get, AddOrUpdate, Romve general methods, such as, at the same time also in netcore abstract IChangeToken (this can do change depend on follow-up, expired callback functions)
Directly to do so, we say that, don't entangled with the good that is bad, no matter you with what is just behind the new different, rather than what the good, the bad
CodePudding user response:
Why do we say so, very simplehttps://www.nuget.org/packages? Q=Microsoft. Extensions. Caching
Look here, look at whether Microsoft and when foreigners like Chinese programmers with
The somebody else don't tangle, everything from Microsoft. Extensions. Caching. Abstractions to abstract
The rest is not the good, the bad,
But how do you want to new,
A new Microsoft. Extensions. Caching. There is nothing wrong with the Memory
A new Microsoft. Extensions. There is nothing wrong with Caching. Essentially a
A new Microsoft. Extensions. Caching. There is nothing wrong with Redis still
CodePudding user response:
System. Web. The HttpRuntime. Cache. The Add (" Jsapi_ticket strTicket, null, DateTime. Now the AddSeconds (time), TimeSpan. Zero, System. Web. Caching. CacheItemPriority. High, null);You threw the blacklist here, set up an invalid time, when you have modified the blacklist, change the database synchronization to the cache