This article is a mirror article of machine translation, please click here to jump to the original article.

View: 18150|Reply: 5

[Source] [Actual combat]. NET/C# exports the cache using StackExchange.Redis fuzzy query

[Copy link]
Posted on 2/13/2022 12:50:33 PM | | | |
Requirements: Some data needs to be exported from the Redis cache via wildcards to troubleshoot issues. NET/C# uses the StackExchange.Redis client to manipulate the Redis cache and export it as a txt file to the local disk. The principle is to filter out all keys through the SCAN command, and then query the value of each key.

The KEYS command in Redis returns all matching keys at once, when there are a lot of keys in Redis, it is a hidden danger for memory consumption and redis server, and for Redis 2.8 and above versions, it provides us with a better command to traverse the keys SCAN.

SCAN returns only a small number of elements per execution, so it can be used in production environments without the problems that can block the server like the KEYS or SMEMBERS commands.

The SCAN command is a cursor-based iterator. This means that each time a command is called, it needs to use the cursor returned by the previous call as the cursor argument for the next call, so as to continue the previous iteration process

When the cursor parameter (i.e., cursor) of the SCAN command is set to 0, the server will start a new iteration, and when the server returns a cursor with a value of 0 to the user, the iteration is over.

Review:

.NET/C# operations Redis unordered collections
https://www.itsvse.com/thread-9622-1-1.html

.net/c# operation redis cache addition, deletion, modification and query [source code]
https://www.itsvse.com/thread-4068-1-1.html

First, we insert 100,000 bars into RedisUser:GUID 格式Data as shown in the figure below:



.NET/C# uses StackExchange.Redis to fuzzly query the "User:*" data and output it to your local disk as a txt file, the source code is as follows:

The renderings are as follows:



(End)





Previous:MongoDB Viewing and Creating Indexes
Next:Front-end JS solves the problem of loss of JSON serialization accuracy
Posted on 2/13/2022 4:28:07 PM |
Let's take a look again.
Posted on 2/14/2022 5:44:42 PM |
Learn to learn
Posted on 3/8/2022 8:55:18 AM |
Learn to learn hhhhhh
Posted on 6/20/2022 10:40:27 PM |
Let's take a look at the solution of the big guy hee hee
Posted on 2/25/2023 4:29:07 PM |
Just need it, thank you
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com