Redis还提供了丰富的客户端,以便支持现阶段流行的大多数编程语言。Redis自身使用ANSI C来编写,并且能够在不产生外部依赖(exte
Redis是一款开源的、高性能的键-值存储(key-value store)。它常被称作是一款数据结构服务器(data structure server)。Redis的键值可以包括字符串(strings)、哈希(hashes)、列表(lists)、集合(sets)和 有序集合(sorted sets)等数据类型。 对于这些数据类型,你可以执行原子操作。例如:对字符串进行附加操作(append);递增哈希中的值;向列表中增加元素;计算集合的交集、并集与差集等。
为了获得优异的性能,Redis采用了内存中(in-memory)数据集(dataset)的方式。根据使用场景的不同,你可以每隔一段时间将数据集转存到磁盘上来持久化数据,或者在日志尾部追加每一条操作命令。
Redis同样支持主从复制(master-slave replication),并且具有非常快速的非阻塞首次同步(non-blocking first synchronization)、网络断开自动重连等功能。同时Redis还具有其它一些特性,其中包括简单的check-and-set机制、 pub/sub和配置设置等,以便使得Redis能够表现得更像缓存(cache)。
Redis还提供了丰富的客户端,以便支持现阶段流行的大多数编程语言。详细的支持列表可以参看Redis官方文档: /clients。Redis自身使用ANSI C来编写,并且能够在不产生外部依赖(external dependencies)的情况下运行在大多数POSIX系统上,例如:Linux、*BSD、OS X和Solaris等。
Redis的安装
说明:Redis的安装版本选取为2.2.6,安装包为redis-2.2.6.tar.gz,系统平台为CentOS 5.5。
1. 解压安装包
使用tar -xzvf redis-2.2.6.tar.gz来解压安装包。假设Redis 解压后目录为redis-2.2.6,绝对路径使用$REDIS_HOME来表示。其目录结构如下所示:
其中,README和INSTALL中包含了编译、安装Redis的简单说明,在正式开始之前请先阅读这两个文件。
2. 编译
进入$REDIS_HOME/src目录,,使用make命令来编译Redis,该编译过程将会产生redis-server二进制文件。
3. 测试
在编译Redis完成之后,最好使用make test命令进行一下测试,但是该步不是必须的。
4. 安装
使用make install来完成Redis的安装。Redis的所有二进制文件将会被安装在/usr/local/bin目录下。
Redis的运行和测试:
假设Redis安装在/usr/local/bin目录下,并且该目录包含在$PATH环境变量的搜索目录中。那么便可以使用redis-server来 运行Redis。如果Redis安装在其他目录中,可以使用/path/to/redis-server来启动Redis,或者将Redis的安装目录添 加到$PATH的搜索目录中。
Redis自带了一个称为redis-cli的命令行客户端,该客户端会在运行make命令的时候自动编译。用户可以使用该客户端完成Redis的一些简单测试或操作。
使用redis-cli来启动该客户端,启动后命令行前缀为:redis>。用户可以在此进行后续操作,这类似于MySQL的命令行模式。
例如,使用如下命令来存储key-value对:
使用get命令来获取所存储的值:
至此,Redis的安装和简单测试便完成了。需要注意的是,在运行make test命令的时候,有时候会出现如下错误:
(cd ..; tclsh8.5 tests/test_helper.tcl --tags "" --file "")
/bin/sh: tclsh8.5: command not found
make: *** [test] Error 127
之所以会出现该错误是因为在运行make test命令时,需要Tcl 8.5的库,而CentOS 5.5自带的版本为8.4。用户可以使用如下命令来查看:
此时,你可以到Tcl的官方网站下载8.5版本,并按照Tcl的安装说明自行安装便可。安装完成后,使用ldconfig再次查看:
此时,再次运行make test命令便可。
1、从官网下载和解压源代码
wget
tar xzf redis-2.2.5.tar.gz
cd redis-2.2.5
2、编译,并使用tcmalloc加速
make USE_TCMALLOC=yes
3、启动redis
./redis-server ./redis.conf
4、验证是否在使用tcmalloc
lsof -n |grep tcmalloc
redis-ser 26689 root mem REG 253,3 1800221 4182039 /usr/local/lib/libtcmalloc.so.0.1.0
redis-ser 26694 root mem REG 253,3 1800221 4182039 /usr/local/lib/libtcmalloc.so.0.1.0
redis-ser 26697 root mem REG 253,3 1800221 4182039 /usr/local/lib/libtcmalloc.so.0.1.0
redis-ser 26701 root mem REG 253,3 1800221 4182039 /usr/local/lib/libtcmalloc.so.0.1.0
下面关于Redis的文章您也可能喜欢,不妨参考下:
Ubuntu 14.04下Redis安装及简单测试
Redis主从复制基本配置
Redis集群明细文档
Ubuntu 12.10下安装Redis(图文详解)+ Jedis连接Redis
Redis系列-安装部署维护篇
CentOS 6.3安装Redis
Redis安装部署学习笔记
Redis配置文件redis.conf 详解
Redis 的详细介绍:请点这里
Redis 的下载地址:请点这里
本文永久更新链接地址:

InnoDBBufferPool reduces disk I/O by caching data and indexing pages, improving database performance. Its working principle includes: 1. Data reading: Read data from BufferPool; 2. Data writing: After modifying the data, write to BufferPool and refresh it to disk regularly; 3. Cache management: Use the LRU algorithm to manage cache pages; 4. Reading mechanism: Load adjacent data pages in advance. By sizing the BufferPool and using multiple instances, database performance can be optimized.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

MySQL is worth learning because it is a powerful open source database management system suitable for data storage, management and analysis. 1) MySQL is a relational database that uses SQL to operate data and is suitable for structured data management. 2) The SQL language is the key to interacting with MySQL and supports CRUD operations. 3) The working principle of MySQL includes client/server architecture, storage engine and query optimizer. 4) Basic usage includes creating databases and tables, and advanced usage involves joining tables using JOIN. 5) Common errors include syntax errors and permission issues, and debugging skills include checking syntax and using EXPLAIN commands. 6) Performance optimization involves the use of indexes, optimization of SQL statements and regular maintenance of databases.

MySQL is suitable for beginners to learn database skills. 1. Install MySQL server and client tools. 2. Understand basic SQL queries, such as SELECT. 3. Master data operations: create tables, insert, update, and delete data. 4. Learn advanced skills: subquery and window functions. 5. Debugging and optimization: Check syntax, use indexes, avoid SELECT*, and use LIMIT.

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.

MySQL is an open source relational database management system that is widely used in Web development. Its key features include: 1. Supports multiple storage engines, such as InnoDB and MyISAM, suitable for different scenarios; 2. Provides master-slave replication functions to facilitate load balancing and data backup; 3. Improve query efficiency through query optimization and index use.

SQL is used to interact with MySQL database to realize data addition, deletion, modification, inspection and database design. 1) SQL performs data operations through SELECT, INSERT, UPDATE, DELETE statements; 2) Use CREATE, ALTER, DROP statements for database design and management; 3) Complex queries and data analysis are implemented through SQL to improve business decision-making efficiency.

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA


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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

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.

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment