Home Backend Development PHP Tutorial redis is installed under windows and used in PHP

redis is installed under windows and used in PHP

Aug 08, 2016 am 09:25 AM
dll php redis windows

1. Introduction to redis
redis is a key-value storage system. Similar to Memcached, it supports storage There are relatively more value types stored, including string (string), list (linked list), set (collection), zset (sorted set) --Ordered sets) and hashes (hash type). These data types all support push/pop, add/remove, intersection, union, difference, and richer operations, and these operations are It's atomic. On this basis, redis supports various different ways of sorting. Like memcached, data is cached in memory to ensure efficiency. The difference is that redis will periodically write updated data to disk or write modification operations to additional record files, and on this basis, master-slave (master-slave) synchronization is achieved.

Redis is a high-performance key-value database. The emergence of redis has largely compensated for the shortcomings of key/value storage such as memcached, and can play a very good supplementary role to relational databases in some situations. It provides Python, Ruby, Erlang, and PHP clients, which are very convenient to use.

2. Install redis under windows
Download address https://github.com/dmajkic/redis/downloads. The downloaded Redis supports 32bit and 64bit. Choose according to your actual situation, I choose 32bit. Copy the 32bit file contents to the directory that needs to be installed, such as: D:devredis-2.4.5.

Open a cmd window, use the cd command to switch to the specified directory (D:devredis-2.4.5) and run redis-server.exe redis.conf. After running, the following interface will appear.

This means that the Redis server has been installed successfully.

Reopen a cmd window, use the cd command to switch to the specified directory (D:devredis-2.4.5) and run redis-cli.exe -h 127.0.0.1 -p 6379, where 127.0.0.1 is the local ip and 6379 is the redis service The default port of the client. The successful operation is shown in the figure below.
In this way, the setup of Redis in windows environment has been completed. Isn’t it very simple?

In this way, the setup of Redis in windows environment has been completed. Isn’t it very simple?

The environment has been set up, it’s time to test it. For example: store a string with key test and value hello word, and then get the key value.

The hell word is output correctly and the test is successful!

3. Used in PHP

Download dll file

http://download.csdn.net/download/bluesky321/5355093

php_redis.dll extension For PHP5.4.x

PHP5.4.x redis extension php_redis.dll

Test platform: Windows XPx32 (FastCGI PHP5.4.9 Nginx 1.4.0)

Contains two versions: Non Thread Safe and Thread Safe

First put php_redis.dll and php_igbinary.dll into the PHP ext folder, and then add the following code to the php.ini configuration file:

extension=php_igbinary.dll

extension=php_redis.dll

Restart the web server

Note: extension=php_igbinary.dll must be placed in front of extension=php_redis.dll, otherwise this extension will not take effect

4. Used in PHP

The code is as follows

1

2

3

4

5

6

<?<span>php

    <span>$redis = <span>new<span> Redis();

    <span>$redis->connect('127.0.0.1',6379<span>);

    <span>$redis->set('test','hello redis'<span>);

    <span>echo <span>$redis->get('test'<span>);

?></span></span></span></span></span></span>

Copy after login

Output hello redis successful!

The above introduces the installation of redis under windows and its use in PHP, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP and Python: Different Paradigms Explained PHP and Python: Different Paradigms Explained Apr 18, 2025 am 12:26 AM

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: An Introduction to the Server-Side Scripting Language PHP: An Introduction to the Server-Side Scripting Language Apr 16, 2025 am 12:18 AM

PHP is a server-side scripting language used for dynamic web development and server-side applications. 1.PHP is an interpreted language that does not require compilation and is suitable for rapid development. 2. PHP code is embedded in HTML, making it easy to develop web pages. 3. PHP processes server-side logic, generates HTML output, and supports user interaction and data processing. 4. PHP can interact with the database, process form submission, and execute server-side tasks.

Choosing Between PHP and Python: A Guide Choosing Between PHP and Python: A Guide Apr 18, 2025 am 12:24 AM

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 vs. Python: Use Cases and Applications PHP vs. Python: Use Cases and Applications Apr 17, 2025 am 12:23 AM

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.

Why Use PHP? Advantages and Benefits Explained Why Use PHP? Advantages and Benefits Explained Apr 16, 2025 am 12:16 AM

The core benefits of PHP include ease of learning, strong web development support, rich libraries and frameworks, high performance and scalability, cross-platform compatibility, and cost-effectiveness. 1) Easy to learn and use, suitable for beginners; 2) Good integration with web servers and supports multiple databases; 3) Have powerful frameworks such as Laravel; 4) High performance can be achieved through optimization; 5) Support multiple operating systems; 6) Open source to reduce development costs.

Can vs code run in Windows 8 Can vs code run in Windows 8 Apr 15, 2025 pm 07:24 PM

VS Code can run on Windows 8, but the experience may not be great. First make sure the system has been updated to the latest patch, then download the VS Code installation package that matches the system architecture and install it as prompted. After installation, be aware that some extensions may be incompatible with Windows 8 and need to look for alternative extensions or use newer Windows systems in a virtual machine. Install the necessary extensions to check whether they work properly. Although VS Code is feasible on Windows 8, it is recommended to upgrade to a newer Windows system for a better development experience and security.

PHP's Impact: Web Development and Beyond PHP's Impact: Web Development and Beyond Apr 18, 2025 am 12:10 AM

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

vscode cannot install extension vscode cannot install extension Apr 15, 2025 pm 07:18 PM

The reasons for the installation of VS Code extensions may be: network instability, insufficient permissions, system compatibility issues, VS Code version is too old, antivirus software or firewall interference. By checking network connections, permissions, log files, updating VS Code, disabling security software, and restarting VS Code or computers, you can gradually troubleshoot and resolve issues.

See all articles