current location:Home > Technical Articles > Database > Redis

  • How to implement concurrent queuing based on redis optimistic locking
    How to implement concurrent queuing based on redis optimistic locking
    There is a demand scenario where redis is used to control the number of scrapy runs. When the system background is set to 4, scapry is only allowed to start 4 tasks, and excess tasks are queued. Overview I recently built a django+scrapy+celery+redis crawler system. In addition to running other programs, the host purchased by the customer also needs to run the program I developed, so it is necessary to manually control the number of scrapy instances to avoid too many crawlers. Put a burden on the system. Process design 1. The crawler task is initiated by the user in the form of a request, and all user requests are uniformly entered into celery for queuing; 2. The execution of task number control is handed over to reids and saved through celery
    Redis 1778 2023-06-04 09:58:09
  • How SpringBoot uses RedisTemplate to operate Redis data types
    How SpringBoot uses RedisTemplate to operate Redis data types
    Spring encapsulates RedisTemplate to operate Redis, which supports all Redis native APIs. Operation methods for five data structures are defined in RedisTemplate. opsForValue(): operates on strings. opsForList(): Operation list. opsForHash(): operates hash. opsForSet(): Operation set. opsForZSet(): operates an ordered set. Below are examples to understand and apply these methods. What needs special attention here is that the data must be cleared after running the above method, otherwise running it multiple times will result in repeated data operations. (1) Use Maven to add dependency files
    Redis 821 2023-06-04 09:43:38
  • How to use Redis's expiration strategy and memory elimination strategy
    How to use Redis's expiration strategy and memory elimination strategy
    1. Set keyexpirekeyseconds with expiration time. Time complexity: O(1) Set the expiration time of key. After timeout, the key will be automatically deleted. In Redis terminology the timeout associated with a key is volatile. After timeout, it will only be cleared when DEL, SET, or GETSET is executed on the key. This means that conceptually all operations that change the key without replacing it with a new value will keep the timeout unchanged. For example, using INCR to increment the value of a key, executing LPUSH to push a new value into a list, or using HSET to change a hash field will keep the timeout unchanged. Use the PERSIST command to clear the timeout so that it
    Redis 1422 2023-06-04 09:14:42
  • How to solve Redis related problems
    How to solve Redis related problems
    Redis persistence mechanism Redis is an in-memory database that supports persistence. It synchronizes data in memory to hard disk files through the persistence mechanism to ensure data persistence. When Redis is restarted, the data can be restored by reloading the hard disk files into the memory. Implementation: Create a fork() child process separately, copy the database data of the current parent process to the memory of the child process, and then write it to a temporary file by the child process. After the persistence process is over, replace it with this temporary file. snapshot file, then the child process exits and the memory is released. RDB is the default persistence method of Redis. According to a certain time period strategy, the memory data is saved to a binary file on the hard disk in the form of a snapshot. That is Sn
    Redis 1271 2023-06-04 08:33:02
  • What are the technical points of Redis?
    What are the technical points of Redis?
    1. Why use Redis? The author believes that using Redis in a project is mainly considered from two perspectives: performance and concurrency. Of course, Redis also has other functions that can do distributed locks and other functions, but if it is just for other functions such as distributed locks, there are other middleware (such as Zookpeer, etc.) that can be used instead, and it is not necessary to use Redis. Therefore, this question is mainly answered from two perspectives: performance and concurrency: 1. Performance is shown in the figure below. When we encounter SQL that takes a particularly long time to execute and the results do not change frequently, it is especially suitable to put the running results in into cache. In this way, subsequent requests will be read from the cache, so that requests can be responded to quickly. Off topic: I suddenly want to talk about this quick response
    Redis 1118 2023-06-04 08:27:09
  • Redis cluster instance analysis
    Redis cluster instance analysis
    1. WhyK8s1. Resource isolation. The current RedisCluster is deployed on a physical machine cluster. In order to improve resource utilization and save costs, Redis clusters of multiple business lines are mixed. Because there is no CPU resource isolation, it often happens that the CPU usage of a Redis node is too high, causing other Redis cluster nodes to compete for CPU resources, causing delay jitter. Because different clusters are mixed, such problems are difficult to locate quickly and affect operation and maintenance efficiency. K8s containerized deployment can specify CPUrequest and CPUlimit, which improves resource utilization and avoids resource contention. 2. Automated deployment The current deployment process of RedisCluster on physical machines is very cumbersome.
    Redis 1791 2023-06-04 08:21:01
  • How to configure sequence and deserialization of RedisTemplate in Redis
    How to configure sequence and deserialization of RedisTemplate in Redis
    RedisTemplate configuration sequence and deserialization For redis operations, springboot has a good encapsulation, that is springdataredis. A highly encapsulated RedisTemplate class is provided to perform a series of redis operations, and the connection pool is automatically managed; at the same time, the transaction encapsulation operation is handed over to the container for processing. For the "serialization and deserialization" of data, multiple strategies (RedisSerializer) are provided. The default is to use JdkSerializationRedisSerializer, as well as StringRedisSerializer and JacksonJsonR.
    Redis 1705 2023-06-03 21:25:08
  • What are the methods of using Redis integer collection?
    What are the methods of using Redis integer collection?
    1. Overview of Sets For sets, I believe everyone is familiar with STL's set. Its underlying implementation is a red-black tree. Regardless of insertion, deletion, or search, the time complexity is O(logn). Of course, if a hash table is used to implement a collection, insertion, deletion, and search can all reach O(1). So why does the collection use red-black trees and not hash tables? I think the biggest possibility is based on the characteristics of the set itself. The set has its own unique operations: intersection, union, and difference. These three operations are all O(n) for hash tables. Based on this, it is more appropriate to use an ordered red-black tree than an unordered hash table. 2. Redis integer set (intset) The integer set we are going to talk about today, also called intset, is Redis
    Redis 1140 2023-06-03 21:18:54
  • What is the command to check the redis version in Linux?
    What is the command to check the redis version in Linux?
    Two commands to check the redis version on Linux 1, redis-server–version and redis-server-v2, redis-cli–version and redis-cli-v
    Redis 3297 2023-06-03 20:58:01
  • How does redis realize real-time page updates and automatic online updates?
    How does redis realize real-time page updates and automatic online updates?
    Requirement description: Some pages need to be configured with advertisements or event promotion images. Advertisements or activities need to be able to go online and offline at any time, automatically go offline after expiration, and automatically go online when the time comes. For example: the current time is 2019-2-2216:16:13. You need to configure the reward collection activity on the payment completion page. The activity must be online on time at 2019-3-1000:00:00 and end at 2019-3-3023:59:59. Activity. So the desired effect is that after configuring the activity at any time before the activity goes online, the page will automatically go online when the time comes. There may also be multiple other activities or advertisements. The number of advertisements on each page is variable, and the online and offline times may be different for different pages. Other pages also need to implement such functions, and the activities between pages are not necessarily the same. demand points
    Redis 1444 2023-06-03 20:56:17
  • Redis cache example code analysis
    Redis cache example code analysis
    1. Introduction 1. Scenario Since the data dictionary does not change very frequently, and the system accesses the data dictionary more frequently, it is necessary for us to store the data in the data dictionary in the cache to reduce database pressure and improve access speed. Here, we use Redis as the distributed cache middleware of the system. 2. RedisTemplate In the SpringBoot project, SpringDataRedis is integrated by default. SpringDataRedis provides a very convenient operation template for Redis, RedisTemplate, and can automatically manage the connection pool. 2. Introduce Redis1 and integrate the Redisservice-base module into the project.
    Redis 1609 2023-06-03 20:37:56
  • How to solve Redis buffer overflow
    How to solve Redis buffer overflow
    Buffer is a part of memory space. In other words, a certain amount of storage space is reserved in the memory space. These storage spaces are used to buffer input or output data. This reserved space is called a buffer. 1. Impact of Redis buffer overflow In Redis, there are three main scenarios where the concept of buffer is used. When communicating between the client and the server, it is used to temporarily store the command data sent by the client, or the data results returned by the server to the client. When synchronizing data between the master and slave nodes, Redis uses the buffer to temporarily store When the write commands and data received by the master node are persisted in AOF by Redis, Redis also uses the concept of buffer to avoid frequent disk writes.
    Redis 1249 2023-06-03 20:13:41
  • How to correctly set the configuration parameters of mongodb and redis development environment and production environment
    How to correctly set the configuration parameters of mongodb and redis development environment and production environment
    When we write code, we usually develop it on our own computer first, and then deploy the code to the server. If a piece of code involves reading and writing a database, or accessing some other online service interfaces, then during development, in order not to affect the online environment, we usually separate the database in the test environment and the database in the online environment. For example, our program needs to access MongoDB and Redis, so in the code, we may write like this: importpymongoimportredishandler=pymongo.MongoClient('mongodb://username:password@127.0.0.
    Redis 1629 2023-06-03 20:04:15
  • How to analyze Redis knowledge points
    How to analyze Redis knowledge points
    It is a data structure rather than a type. Many articles will say that redis supports 5 commonly used data types. This is actually a big ambiguity. All binary data stored in redis is actually a byte array (byte[]). These byte data have no data type. They can only be turned into a string, integer or object after decoding them in a reasonable format. , only then does it have a data type. This must be remembered. So anything that can be converted into a byte array (byte[]) can be stored in redis. No matter if it is a string, number, object, picture, sound, video, or file, just change it into a byte array. Therefore, String in redis does not refer to a string, it actually means
    Redis 1150 2023-06-03 20:02:11
  • What is the installation method of Redis6 under Centos7?
    What is the installation method of Redis6 under Centos7?
    Installation environment: centos7.9, redis6.0.8 nanny-level installation tutorial 1. Download the Redis compressed package from the Internet wgethttp://download.redis.io/releases/redis-6.0.8.tar.gz2. Unzip tar-xfredis-6.0 .8.tar.gz3. Enter the decompressed folder cdredis-6.0.84 and compile redismake#compile redis. If you find that the final compilation fails, check the gcc version and execute the following commands in order to upgrade the gcc version yum-yinstallcentos-release-
    Redis 2243 2023-06-03 19:19:25

Tool Recommendations

jQuery enterprise message form contact code

jQuery enterprise message form contact code is a simple and practical enterprise message form and contact us introduction page code.
form button
2024-02-29

HTML5 MP3 music box playback effects

HTML5 MP3 music box playback special effect is an mp3 music player based on HTML5 css3 to create cute music box emoticons and click the switch button.

HTML5 cool particle animation navigation menu special effects

HTML5 cool particle animation navigation menu special effect is a special effect that changes color when the navigation menu is hovered by the mouse.
Menu navigation
2024-02-29

jQuery visual form drag and drop editing code

jQuery visual form drag and drop editing code is a visual form based on jQuery and bootstrap framework.
form button
2024-02-29

Organic fruit and vegetable supplier web template Bootstrap5

An organic fruit and vegetable supplier web template-Bootstrap5
Bootstrap template
2023-02-03

Bootstrap3 multifunctional data information background management responsive web page template-Novus

Bootstrap3 multifunctional data information background management responsive web page template-Novus
backend template
2023-02-02

Real estate resource service platform web page template Bootstrap5

Real estate resource service platform web page template Bootstrap5
Bootstrap template
2023-02-02

Simple resume information web template Bootstrap4

Simple resume information web template Bootstrap4
Bootstrap template
2023-02-02

Cute summer elements vector material (EPS PNG)

This is a cute summer element vector material, including the sun, sun hat, coconut tree, bikini, airplane, watermelon, ice cream, ice cream, cold drink, swimming ring, flip-flops, pineapple, conch, shell, starfish, crab, Lemons, sunscreen, sunglasses, etc., the materials are provided in EPS and PNG formats, including JPG previews.
PNG material
2024-05-09

Four red 2023 graduation badges vector material (AI EPS PNG)

This is a red 2023 graduation badge vector material, four in total, available in AI, EPS and PNG formats, including JPG preview.
PNG material
2024-02-29

Singing bird and cart filled with flowers design spring banner vector material (AI EPS)

This is a spring banner vector material designed with singing birds and a cart full of flowers. It is available in AI and EPS formats, including JPG preview.
banner picture
2024-02-29

Golden graduation cap vector material (EPS PNG)

This is a golden graduation cap vector material, available in EPS and PNG formats, including JPG preview.
PNG material
2024-02-27

Home Decor Cleaning and Repair Service Company Website Template

Home Decoration Cleaning and Maintenance Service Company Website Template is a website template download suitable for promotional websites that provide home decoration, cleaning, maintenance and other service organizations. Tip: This template calls the Google font library, and the page may open slowly.
Front-end template
2024-05-09

Fresh color personal resume guide page template

Fresh color matching personal job application resume guide page template is a personal job search resume work display guide page web template download suitable for fresh color matching style. Tip: This template calls the Google font library, and the page may open slowly.
Front-end template
2024-02-29

Designer Creative Job Resume Web Template

Designer Creative Job Resume Web Template is a downloadable web template for personal job resume display suitable for various designer positions. Tip: This template calls the Google font library, and the page may open slowly.
Front-end template
2024-02-28

Modern engineering construction company website template

The modern engineering and construction company website template is a downloadable website template suitable for promotion of the engineering and construction service industry. Tip: This template calls the Google font library, and the page may open slowly.
Front-end template
2024-02-28