【Redis1】Redis数据库的学习与实践—安装与部署
Redis数据库的学习与实践安装与部署 一:Redis数据库简介: RedisRemote DictionaryServer,可以直接理解为远程字典服务。 这里摘抄一段Redis官网上的话似乎更能准确的概述Redis的含义:Redis is an open source,BSD licensed, advanced key-valuecache and
Redis数据库的学习与实践—安装与部署
一:Redis数据库简介:
Redis—Remote DictionaryServer,可以直接理解为远程字典服务。
这里摘抄一段Redis官网上的话似乎更能准确的概述Redis的含义:Redis is an open source,BSD licensed, advanced key-valuecache and store.It is often referred to as a datastructure server since keys can contain strings,hashes,lists,sets,sorted sets,bitmapsand hyperloglogs.
Redis数据库是一个高性能的key-value数据库,Redis 是完全开源免费的,遵守BSD协议,先进的key - value持久化产品。它通常被称为数据结构服务器,因为值(value)可以是字符串(String), 哈希(Map),列表(list), 集合(sets)和有序集合(sorted sets)等类型。这些数据类型都支持push/pop,add/remove及取交集和并集及更丰富的操作,Redis支持各种不同方式的排序。为了保证效率,数据都是缓存在内存中,它也可以周期性的把更新的数据写入磁盘或者把修改操作写入追加的记录文件。
二:Redis数据库使用场合:
目前全球最大的Redis用户是新浪微博,在新浪有200多台物理机,400多个端口正在运行这Redis,有+4G的数据在Redis上来为新浪微博用户提供服务。
在新浪微博Redis的部署场景很多,大概分为如下的两种:
1:应用程序直接访问Redis数据库;
2:应用程序直接访问Redis,只有Redis访问失败的时候才会访问MySQL。
Redis数据库提供多种灵活的数据结构和数据操作,为不同的大数据构建不同的数据结构。
具体的适用场景:
1:取最新N个数据的请求;
2:排行榜应用,取TOP N操作;
3:需要精确设定过期时间的应用;
4:计数器应用;
5:Uniq操作,获取某段时间所有数据排重值;
6:实时系统,反垃圾系统;
7:Pub/Sub(订阅/发布)构建实时消息系统;
8:构建队列系统;
9:缓存。
Redis,Mysql,MongoDB三种数据库的比较:
不同\数据库 |
Redis |
Mysql |
MongoDB |
1 |
库 |
库 |
库 |
2 |
无 |
表 |
集合 |
3 |
无 |
字段/行/列 |
无 |
三:Redis的安装与部署:
1:下载,解压和安装:
在官网下载编译后的,适用于64位Linux系统的redis-2.8.13.tar.gz,然后拷贝至Linux系统下,并执行下列命令:
#step1 $ tar zxvf redis-2.8.13.tar.gz $ mv redis-2.8.13 redis $ cd redis $ make #step2 $ cd redis/src $ make install |
2:启动Redis:
Redis的默认端口是:6379
#启动redis服务 $ cd redis $ cd redis/src $ redis-server #设置redis配置文件 $ cd redis $ sudo vim redis.conf |
3:修改配置文件和设置后台运行:
首先修改redis.conf文件:
$ sudo vim reids.conf |
然后修改配置选项daemonize为yes,然后保存退出
启动redis,并设置配置文件:
$ redis-server /home/djy/toolkit/redis/redis.conf |
设置成功之后,验证是否成功:
$ ps –ef | grep redis |
运行结果显示如下:
djy 6262 2972 0 01:37 pts/1 00:00:00 redis-server *:6379 djy 9539 2972 0 02:00 pts/1 00:00:00 grep redis |
查看6379端口的状态:
$ netstat –tunpl | grep 6379 |
4:进入Redis的客户端redis-cli
$ cd src $ redis-cli |
运行后的结果如下,则表示进入客户端成功:
djy@ubuntu:~/toolkit/redis/src$ redis-cli 127.0.0.1:6379> 127.0.0.1:6379> 127.0.0.1:6379> 127.0.0.1:6379> |
5:关闭redis-server
#第一种方式 $pkill redis-server #第二种方式 $redis-cli shutdown |

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

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

1. Start the [Start] menu, enter [cmd], right-click [Command Prompt], and select Run as [Administrator]. 2. Enter the following commands in sequence (copy and paste carefully): SCconfigwuauservstart=auto, press Enter SCconfigbitsstart=auto, press Enter SCconfigcryptsvcstart=auto, press Enter SCconfigtrustedinstallerstart=auto, press Enter SCconfigwuauservtype=share, press Enter netstopwuauserv , press enter netstopcryptS

1. Introduction Over the past few years, YOLOs have become the dominant paradigm in the field of real-time object detection due to its effective balance between computational cost and detection performance. Researchers have explored YOLO's architectural design, optimization goals, data expansion strategies, etc., and have made significant progress. At the same time, relying on non-maximum suppression (NMS) for post-processing hinders end-to-end deployment of YOLO and adversely affects inference latency. In YOLOs, the design of various components lacks comprehensive and thorough inspection, resulting in significant computational redundancy and limiting the capabilities of the model. It offers suboptimal efficiency, and relatively large potential for performance improvement. In this work, the goal is to further improve the performance efficiency boundary of YOLO from both post-processing and model architecture. to this end

In PHP development, the caching mechanism improves performance by temporarily storing frequently accessed data in memory or disk, thereby reducing the number of database accesses. Cache types mainly include memory, file and database cache. Caching can be implemented in PHP using built-in functions or third-party libraries, such as cache_get() and Memcache. Common practical applications include caching database query results to optimize query performance and caching page output to speed up rendering. The caching mechanism effectively improves website response speed, enhances user experience and reduces server load.

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())

First you need to set the system language to Simplified Chinese display and restart. Of course, if you have changed the display language to Simplified Chinese before, you can just skip this step. Next, start operating the registry, regedit.exe, directly navigate to HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlNlsLanguage in the left navigation bar or the upper address bar, and then modify the InstallLanguage key value and Default key value to 0804 (if you want to change it to English en-us, you need First set the system display language to en-us, restart the system and then change everything to 0409) You must restart the system at this point.

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

Both Laravel and CodeIgniter support cloud platform deployment. Laravel provides native support out of the box, simplifying the deployment process. CodeIgniter requires additional configuration and modifications to run in a cloud environment.

How to integrate GoWebSocket with a database: Set up a database connection: Use the database/sql package to connect to the database. Store WebSocket messages to the database: Use the INSERT statement to insert the message into the database. Retrieve WebSocket messages from the database: Use the SELECT statement to retrieve messages from the database.
