current location:Home > Technical Articles > Database > Redis
- Direction:
- All web3.0 Backend Development Web Front-end Database Operation and Maintenance Development Tools PHP Framework Daily Programming WeChat Applet Common Problem Other Tech CMS Tutorial Java System Tutorial Computer Tutorials Hardware Tutorial Mobile Tutorial Software Tutorial Mobile Game Tutorial
- Classify:
-
- How to implement SMS login in Redis shared session application
- 1. Implementing SMS login based on session 1.1 SMS login flow chart 1.2 Implementing sending SMS verification code Front-end request description: Description of request method POST request path /user/code request parameter phone (phone number) return value No back-end interface implementation: @Slf4j@ ServicepublicclassUserServiceImplextendsServiceImplimplementsIUserService{@OverridepublicResultsendCode(Stringphone,HttpSessionsession){//1. Verify mobile phone number if
- Redis 1604 2023-06-03 15:11:05
-
- How to use django redis
- 1. Explain that redis, as a cache database, plays a great role in all aspects. Python supports operating redis. If you use Django, there is a redis library specially designed for Django, namely django-redis2. Install pipinstalldjango-redis3. Configuration 3.1 To configure redis, open the Django configuration file, such as setting.py, and set the CACHES item CACHES={"default":{"BACKEND":"django_redis.cache.Redis
- Redis 1486 2023-06-03 14:53:13
-
- How to apply the 5 data types in Redis
- Problems with the MySql+Memcached architecture. In fact, MySQL is suitable for massive data storage. Hotspot data is loaded into the cache through Memcached to speed up access. Many companies have used such an architecture, but as the amount of business data continues to increase, and access As the volume continues to grow, we have encountered many problems: 1. MySQL needs to continuously remove databases and tables, and Memcached also needs to continue to expand. The expansion and maintenance work takes up a lot of development time. 2. Data consistency issues between Memcached and MySQL database. 3. Memcached data hit rate is low or the machine is down. A large number of accesses directly penetrate to the DB, and MySQL has no
- Redis 1451 2023-06-03 14:51:15
-
- What are the eight classic problems of Redis?
- 1. Why use Redis analysis: The blogger feels that using redis in the project is mainly considered from two perspectives: performance and concurrency. Of course, redis also has other functions such as distributed locks, but if it is just for other functions such as distributed locks, there are other middleware (such as zookpeer, etc.) instead, and it is not necessary to use redis. Therefore, this question is mainly answered from two perspectives: performance and concurrency. Answer: As shown below, it is divided into two points (1) Performance As 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 into the cache. In this way, subsequent requests will be read from the cache, so that requests can be responded to quickly. Digression: suddenly
- Redis 1459 2023-06-03 14:44:48
-
- How to clear all data in Redis
- Summary of steps to clear all data in Redis 1. Open the cmd command window and switch to the bin folder in the Redis installation directory 2. In the cmd command window, enter the connection Redis command: redis-cli.exe-h127.0.0.1-p63893, connect After success, if Redis configures the password mode, you first need to enter a legal password. If there is no configuration, you can directly filter this step authabc1234. In the cmd command window, enter the command to clear all Redis data: flushallRedis data clearing policy Redis clearing expired policy redis setting key Expired name setnx, when the key expires, k will be automatically cleared
- Redis 3932 2023-06-03 14:25:19
-
- What are the Redis specifications?
- Redis has powerful functions and rich data types. No matter how fast the system is, it cannot withstand crazy abuse. By disabling some high-risk functions and hanging the shackles of development, the business can consider problems with concise and general ideas instead of being bound to a certain implementation. Redis will have different persistence strategies and eviction strategies based on different uses. Therefore, before using and applying for a Redis cluster, please clarify whether it is used for caching or storage. The redis cluster has two modes: master-slave and cluster, each with its own advantages and disadvantages. The following specifications do not distinguish between cluster modes. We explain them in terms of usage scenarios and operational restrictions. Using specifications to distinguish hot and cold data Although redis supports persistence, storing all data in redis costs
- Redis 1370 2023-06-03 14:19:49
-
- What are the methods for operating redis in python?
- Python operates redis and uses a connection pool: redis-py uses connectionpool to manage all connections to a redisserver to avoid the overhead of establishing and releasing a connection each time. By default, each Redis instance maintains its own connection pool. You can directly establish a connection pool and then use it as parameter Redis, so that multiple Redis instances can share a connection pool. defgetcoon():pool=redis.ConnectionPool(host='192.168.25.126',port=6379,password
- Redis 1068 2023-06-03 13:45:03
-
- How Redis uses ZSET to implement message queue
- 1. Redis uses zset as a message queue. How to handle the message backlog and change the consumer's consumption capacity: You can increase the number of consumers, or optimize the consumer's consumption capacity so that it can process messages faster. At the same time, parameters such as the number of consumers, consumption rate, and priority can be dynamically adjusted according to the number of messages in the message queue. Filter expired messages: Move expired messages out of the message queue to reduce the length of the queue so that consumers can consume unexpired messages in a timely manner. You can use the zremrangebyscore() method provided by Redis to clean up expired messages. Segment the message: Segment the message and distribute it to different message queues so that no
- Redis 1429 2023-06-03 13:14:38
-
- Analysis of Linux Redis Automated Mining Infection Worm Instances
- 1. Background Since the disclosure of the attack method of obtaining root permissions of Linux system through Redis unauthorized issue, due to its ease of use, hackers who use this issue to invade Linux services for mining, scanning, etc. have been emerging in endlessly; and in many cases that exploit this issue Among the cases of invading servers for black production, there is one type that exploits this problem for mining and uses pnscan to automatically scan and infect other machines; this type of attack has always existed, but has shown an increasing trend in recent times, and was recently captured Many times, we will make a detailed analysis on it. 2. Vulnerability Description First, let me explain the exploited vulnerability. By default, Redis will be bound to 0.0.0.0:6379.
- Redis 1550 2023-06-03 12:48:10
-
- How to use Redis
- Usage scenarios In my project, there is a function provided for Autocomplete, and the amount of data is probably tens of thousands. In this article, I use the example of name retrieval to illustrate. For the list, please click on the Demo from the author of Redis. Such a list is full of user names. For example, there is a user object in our system: publicClassUser{publicstringId{get;set;}publicstringName{get;set;}....publicstringUserHead{get;set;}} in the system A user's drop-down list is needed. Due to the large amount of data, it cannot be displayed all at once, so an Auto
- Redis 1288 2023-06-03 12:48:00
-
- How to apply Redis stand-alone cache of SpringBoot caching mechanism
- Redis stand-alone cache is the same as Ehcache. If Redis exists in the classpath and Redis has been configured, RedisCacheManager will be used as the cache provider by default. The steps for using Redis stand-alone cache are as follows: 1. Create a project, add cache dependencies, and create a SpringBoot project. Add spring-boot-starter-cache and Redis dependencies org.springframework.bootspring-boot-starter-cacheorg.springframework.bootspring-boot-
- Redis 1021 2023-06-03 12:41:50
-
- How to solve the double-write consistency problem between Redis and MySQL
- Double-write consistency between Redis and MySQL refers to how to ensure the data consistency between the two (the content is the same or as close as possible) in the scenario where the cache and the database are used to store data at the same time (mainly when there is high concurrency). Normal business process: There is no problem with reading. The key lies in the write (update) operation. This will cause several problems. Here, the database is updated first, and then the cache is operated. But for cache operations, should we update the cache or delete the cache? Or why not operate (delete, update) the cache first and then update the database? To sum up, should we operate the cache first and then the database, or should we operate the database first and then the cache? Let’s continue with these questions. First, let’s talk about the operation cache, which includes two types: update cache and delete.
- Redis 1435 2023-06-03 12:28:10
-
- What causes Redis memory fragmentation and what is the principle of Pipeline?
- Memory fragmentation How does memory fragmentation occur? Redis has its own internal memory allocator, the default is jemalloc, which manages the application and release of memory in order to improve the efficiency of memory usage. The memory allocator allocates memory according to a fixed size, not exactly according to the memory size requested by the program. For example, if the program applies for a 20-byte memory, the memory allocator will allocate a 32-byte memory space. This is done to reduce the number of allocations. Redis will apply for different sizes of memory space to store different types of data for different businesses. Since the memory is allocated according to a fixed size and will be larger than the actual requested memory, memory fragmentation will occur in this process. For example: Let’s use a high-speed rail carriage to illustrate. Suppose a car
- Redis 1390 2023-06-03 12:16:41
-
- What are the pitfalls of redis distributed locks?
- 1. Non-atomic operations use redis distributed locks. The first thing we think of may be the setNx command. if(jedis.setnx(lockKey,val)==1){jedis.expire(lockKey,timeout);} It’s easy, divide three times five by two, and we can write the code. This code can indeed lock successfully, but have you found any problems? The locking operation and the subsequent setting of the timeout are separate and are not atomic operations. If the lock is successful but the timeout setting fails, the lockKey will never expire. If in a high-concurrency scenario, a large number of lockKeys are successfully locked but will not fail, it may directly lead to redi failure.
- Redis 1520 2023-06-03 12:03:24
-
- How Redis speeds up Spark
- ApacheSpark has gradually become a model for the next generation of big data processing tools. By borrowing from open source algorithms and distributing processing tasks across clusters of compute nodes, Spark and Hadoop generation frameworks easily outperform both in the types of data analysis they can perform on a single platform and in the speed with which they can perform these tasks. over traditional frameworks. Spark uses memory to process data, making it significantly faster (up to 100 times faster) than disk-based Hadoop. But with a little help, Spark can run even faster. If you combine Spark with Redis (a popular in-memory data structure storage technology), you can once again significantly improve the performance of processing analysis tasks. This is due to Red
- Redis 1492 2023-06-03 11:45:36