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 install redis and redis extension on Ubuntu
- 1. Download the latest source code package and copy the link address wgethttp://download.redis.io/releases/redis-x.x.x.tar.gz. Warm reminder: the redis version number of the redis code downloaded above is based on your own version. Don’t blindly Copy 2. Unzip and install a. Unzip tarzxvfredis-x.x.x.tar.gzb. Install cdredis-x.x.xmakec.make. After completion, redis-related programs (redis-cli, r
- Redis 1341 2023-05-26 17:52:40
-
- How to implement Redis using HyperLogLog
- 1. Overview Redis added the HyperLogLog data structure in version 2.8.9 for cardinality statistics. The advantage is that when the number of input elements is very large, the space required to calculate the cardinality is relatively small and generally constant. In Redis, each HyperLogLog key only costs 12KB of memory to calculate the cardinality of nearly 2^64 different elements. This is in sharp contrast to the calculation of cardinality, where a collection with more elements consumes more memory. However, because HyperLogLog only calculates the base based on the input elements and does not store the input elements themselves, HyperLogLog cannot return each element of the input like a collection. 2. What is cardinality? For example, a data set
- Redis 830 2023-05-26 17:41:25
-
- How to use Redis word segmentation index method
- The word segmentation index method is the only method that I feel is more feasible and consistent with the characteristics of redis after practicing it and combining it with the opinions given by my predecessors in the previous article. However, in the end, it is still not as efficient as memory. For detailed implementation ideas, please see the Redis author's blog (Reference 1). The example here is still based on UserName, in English, and only does word segmentation with a length of 3 for phrases. Please expand by yourself for other scenarios. First, based on AutoComplete's letter search, we need to do a word segmentation for all Names, that is: abc => (a, ab, abc) Then enter a, we will directly get the content in seta, enter ab, we will directly get the ab set Content. Then we start the conversion, first we
- Redis 1018 2023-05-26 17:28:52
-
- How to realize the identification and exchange of hot and cold data in Redis
- Background The Redis hybrid storage product is a hybrid storage product independently developed by Alibaba Cloud that is fully compatible with the Redis protocol and features. By storing part of the cold data on the disk, while ensuring that most access performance does not decrease, user costs are greatly reduced and the memory limit on the data volume of a Redis single instance is exceeded. Among them, the identification and exchange of hot and cold data are key factors in the performance of hybrid storage products. Hot and cold data is defined in Redis hybrid storage. The ratio of memory to disk is freely selectable by the user: a Redis hybrid storage instance considers all Keys to be hot data, ensuring the performance of all Key access requests at the expense of a small amount of memory. Be efficient and consistent. As for the Value part, when there is insufficient memory,
- Redis 850 2023-05-26 17:23:03
-
- What is the method to start Redis in Linux system?
- Redis is a high-performance dictionary database. Its emergence solves the problems of memcached and keyvalue storage. Below, the editor of Liangxu Tutorial Network will share with you how to start Redis. Redis startup command under Linux /usr/local/bin/redis-server/home/data/redis-3.2.1/redis.conf1 If you do not know the location of the redis-server file, enter the following command to query the location find/-nameredis-server1 to check if Started successfully: netstat-nplt1
- Redis 1330 2023-05-26 17:22:06
-
- How to use the command to delete keys in batches in Redis
- There is no command to directly delete keys based on regular expressions in redis, only the delkey1key2... command. However, there is a command to obtain keys through regular expressions in redis: keys "regular expression" can be used to delete keys in batches with the help of the xargs command. Check The key value is passed as a parameter to delredis-clikeys "mailspec*"|xargsdel complete command: [root@localhostredis7001]#redis-cli-h192.169.1.71-p7001-a123456keysem*|x
- Redis 2111 2023-05-26 17:09:38
-
- How to implement delay queue in Redis
- Redis implements delay queue Redis delay queue Redis implements delayed message queue through ordered set (ZSet). ZSet has a Score attribute that can be used to store the delayed execution time. However, an infinite loop of checking tasks is required, which consumes system resources classRedisDelayQueue(object):"""SimpleQueuewithRedisBackenddq=RedisDelayQueue('delay:commtrans')dq.put(5,{'info&
- Redis 2339 2023-05-26 16:44:23
-
- How to use Redis in Go language
- Install the dependency package. Use the third-party library go-redis in Go language. Go-redis supports connecting to Sentinel and cluster mode Redis. Use the following command to download and install: goget-ugithub.com/go-redis/redis/v8 to connect redis and create a new go file, introduce github.com/go-redis/redis/v8 into the project, initialize redis.Client, not much nonsense Say, go directly to the code. packagemainimport("context""fmt""github.com/go-redi
- Redis 1193 2023-05-26 16:43:06
-
- How to build an access frequency control module with Redis
- Principle overview: The program will determine a time slice. The smaller the time slice, the higher the control accuracy. An access control involves multiple time slices. If the program requires adding an access record at a certain time, it will first calculate the time slice to be used based on the current time, and add 1 to the counter of this time slice. When the program determines how many times it has been accessed in a period of time, it will first calculate how many time slices this period of time contains, then take out all these time slices, add the counter and return. The principle introduction is here, and the program-related source code is here (nodejs). How to use Redis to build an access frequency control module. Usage example (nodejs): varredback=require(
- Redis 1546 2023-05-26 16:41:35
-
- How to integrate redis with springboot
- 1.pom.xml添加依赖org.springframework.bootspring-boot-starterorg.springframework.bootspring-boot-starter-weborg.projectlomboklomboktrueorg.springframework.bootspring-boot-starter-testtestorg.springframework.bootspring-boot-starter-data-redis2.application-
- Redis 947 2023-05-26 16:26:36
-
- How Node.js operates redis to add query function
- An example of the installation of the redis server will not be introduced here, the focus is not here. Those who are interested can install it themselves. For a new module, we need to install the redis module in our project before it can be used. Command cnpminstallredis to create a new redis.js file. The code is as follows: //Introduce redis varredis=require("redis");//Create a redis client varclient=redis.createClient("6379","127.0.0.1");// Connection error handling c
- Redis 1244 2023-05-26 16:26:30
-
- What are the ways to establish the Redis master-slave architecture?
- The instances of redis built in the master-slave environment are all master nodes by default, so we need to modify some configurations to build the master-slave architecture. The master-slave architecture of redis is relatively simple to build. Redis provides three ways to build the master-slave architecture. Architecture, we will introduce it later. Before introducing it, we must first understand the characteristics of the master-slave architecture: In the master-slave architecture, there is a master node (master) and at least one slave node (slave), and data replication is one-way. , can only be copied from the master node to the slave node, not from the slave node to the master node. How to establish the master-slave architecture There are three ways to establish the master-slave architecture: Add slaveof{masterHost}{m to the Redis.conf configuration file
- Redis 1146 2023-05-26 16:23:07
-
- Example analysis of the implementation principle of redis distributed lock
- First of all, in order to ensure that distributed locks are available, we must at least ensure that the lock implementation meets the following four conditions at the same time: 1. Mutual exclusivity. At any time, only one client can hold the lock. 2. Deadlock will not occur. Even if a client crashes while holding the lock without actively unlocking it, it is guaranteed that other clients can subsequently lock it. 3. Fault-tolerant. As long as most Redis nodes are running normally, the client can lock and unlock. 4. To untie the bell, one must tie the bell. The locking and unlocking must be done by the same client. The client itself cannot unlock the lock added by others. The following is the code implementation. First, we need to introduce the Jedis open source component through Maven and add the following code to the pom.xml file: org.springf
- Redis 1133 2023-05-26 16:19:14
-
- Why does Redis introduce multi-threading?
- 1. Problem Overview Versions after Redis 6.0 abandoned the design of the single-threaded model. Redis, which originally ran with a single thread, also began to selectively use the multi-threaded model. At first glance, it seems that the author of Redis is so awesome, but he cannot escape the "law of true fragrance". "If you think about it carefully, this question can actually be split into two main questions: (1) Why did Redis choose a single-threaded model in the first place (the benefits of single-threading)? (2) Why did Redis add multi-threading after 6.0 (in some cases, single-threading has shortcomings, which can be solved by multi-threading)? In fact, it is not that the author has not escaped the true fragrance theorem, but as time goes by, more and more problems arise. The original design must be somewhat outdated and should be changed.
- Redis 1555 2023-05-26 15:59:10
-
- How to use Go and Lua to solve the inventory and overselling problems in Redis flash sale
- 0. Introduction Go language connects go-redis to connect to the database. If you don’t understand this part yet, it is recommended that you learn this part of knowledge first. In addition, this flash sale mainly solves two problems. The first is the oversold problem, and the other is the inventory problem. There is no special page designed to simulate concurrency. We directly use gorountine and stay for 10 seconds before calling the request. To address the oversold problem, go-redis' watch can be introduced with transaction processing [equivalent to optimistic locking]. The inventory problem is a little more troublesome. You need to use Lua to edit the script, but you don't need to download the Lua compilation environment on your own machine. Go provides related support. For this part, don’t panic, its basic structure is as follows
- Redis 1052 2023-05-26 15:57:41