


Learn about Redis
Redis is an open source, network-enabled, memory-based, key-value database. It is written in ANSI C and provides APIs in multiple languages. It is almost not difficult to get started, and it only takes a few minutes. You can complete the installation and let it start working smoothly with the application. In other words, with only a small investment of time and effort, you can get immediate and excellent performance improvements, which means it is a very simple caching solution. It supports stored Value types that are not limited to strings, but also supports master-slave synchronization, data persistence, etc. Everyone thinks that Redis is the most popular Key-Value storage database. Someone must ask about Memcached?
Redis VS Memcached
First of all, I just checked the database rankings of DB-Engines.com. Redis ranked ninth and Key-value store first; Memcached ranked 23rd and Key-value store second. . Of course this doesn't mean anything.
Redis supports more data types, including: String, Hash, List, Set; Memcached only supports one String data type.
Redis can support the concept of transactions through commands such as Multi/Watch/Exec and execute a batch of commands atomically; in the Memcached application mode, except for atomic operation commands such as increment/decrement, there is no support for transactions.
Redis can configure the server in the master-slave mode to achieve master-slave synchronous backup, and only supports two persistence solutions; Memcached does not guarantee the validity of the stored data, nor does it perform data persistence. Of course, none of this means anything.
Every thing in this world always has its meaning. Although Memcached's internal memory management mechanism is not as complex as Redis's, it is more practical and efficient because Memcached consumes relatively less memory resources when processing metadata; it also has advantages over Redis in terms of horizontal expansion because of its The design trend and relatively simple function settings. For example, when caching a string or Html page, it is relatively better to use Memcached.
Install Redis under CentOS
1. Download, unzip and install redis. Here is the latest 3.2.5 version downloaded from the official website. It is still downloaded through wget (I like this method).
wget http://download.redis.io/releases/redis-3.2.5.tar.gztar xzf redis-3.2.5.tar.gz mv redis-3.2.5 /usr/local/redis
The above mv redis-3.2.5 /usr/local/redis command is to move the Redis installation file to the installation directory. Of course, you can customize this directory.
2. Enter the directory, compile and install
cd /usr/local/redis make make install
The installation is complete. At this time, you will see redis-server, redis-cli and other executable scripts in the /usr/local/bin/ directory. Enter and take a look. If not, Just go to the unzipped directory and copy it into it.
cd /usr/local/bin/
3. Configure redis.conf
Go back to the /usr/local/redis directory and configure:
cd ../redis vim redis.conf
There are two places to modify here, Just a bind and daemonize will do.
Be careful when configuring bind here. By default, there is only one 127.0.0.1. At this time, you can only connect yourself, and you cannot connect to other LANs. Therefore, multiple IPs need to be configured so that connections can be made within the LAN.
daemonize is to set whether to start Redis in the background. The default is no. Normally, Redis needs to be started as a service, so it is set to yes here.
修改完后,保存退出。
4.启动
cd /usr/local/bin/ redis-server /usr/local/redis/redis.conf netstat -anp | grep 6379
5.测试一下
这里用命令行模式连接上 Redis 进行一个简单的设置、获取缓存测试。
redis-cli #连接 Redis ,默认是本机的。 keys * #查看现在所有 keyset name mafly #设置一个key为`name`,value为`mafly`的缓存对象。 get name #获取key为`name`的缓存
6.关闭 Redis
redis-cli shutdown
通过 netstat 可以看出来端口已经是TIME_WAIT状态了。
总结一下
经过这次安装配置 Redis 的过程,也让我更加了解了一下 Memcached ,也更明白了这两种最流行的 Key-Value 缓存服务的优劣势,当然大多数都是通过网络获取,在实际运用中怎样也在监测中。

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.

In PHP, use the clone keyword to create a copy of the object and customize the cloning behavior through the \_\_clone magic method. 1. Use the clone keyword to make a shallow copy, cloning the object's properties but not the object's properties. 2. The \_\_clone method can deeply copy nested objects to avoid shallow copying problems. 3. Pay attention to avoid circular references and performance problems in cloning, and optimize cloning operations to improve efficiency.

PHP is suitable for web development and content management systems, and Python is suitable for data science, machine learning and automation scripts. 1.PHP performs well in building fast and scalable websites and applications and is commonly used in CMS such as WordPress. 2. Python has performed outstandingly in the fields of data science and machine learning, with rich libraries such as NumPy and TensorFlow.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

WebStorm Mac version
Useful JavaScript development tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Atom editor mac version download
The most popular open source editor