redis在windows下安装和PHP中使用,redisphp
1、redis简介
redis是一个key-value存储系统。和Memcached类似,它支持存
储的value类型相对更多,包括string(字符串)、list(链表)、set(集合)、zset(sorted set
--有序集合)和hashs(哈希类型)。这些数据类型都支持push/pop、add/remove及取交集并集和差集及更丰富的操作,而且这些操作都
是原子性的。在此基础上,redis支持各种不同方式的排序。与memcached一样,为了保证效率,数据都是缓存在内存中。区别的是redis会周期性的把更新的数据写入磁盘或者把修改操作写入追加的记录文件,并且在此基础上实现了master-slave(主从)同步。
Redis 是一个高性能的key-value数据库。 redis的出现,很大程度补偿了memcached这类key/value存储的不足,在部分场合可以对关系数据库起到很好的补充作用。它提供了Python,Ruby,Erlang,PHP客户端,使用很方便。
2、windows下安装redis
下载地址https://github.com/dmajkic/redis/downloads。下载到的Redis支持32bit和64bit。根据自己实际情况选择,我选择32bit。把32bit文件内容拷贝到需要安装的目录下,比如:D:\dev\redis-2.4.5。
打开一个cmd窗口,使用cd命令切换到指定目录(D:\dev\redis-2.4.5)运行 redis-server.exe redis.conf 。运行以后出现如下界面。
这就说明Redis服务端已经安装成功。
重新打开一个cmd窗口,使用cd命令切换到指定目录(D:\dev\redis-2.4.5)运行 redis-cli.exe -h 127.0.0.1 -p 6379,其中 127.0.0.1是本地ip,6379是redis服务端的默认端口。运行成功如下图所示。
这样,Redis windows环境下搭建已经完成,是不是很简单。
这样,Redis windows环境下搭建已经完成,是不是很简单。
环境已经搭建好,总得测试下吧。比如:存储一个key为test,value为hello word的字符串,然后获取key值。
正确输出 hell word,测试成功!
3、PHP中使用
下载 dll文件
http://download.csdn.net/download/bluesky321/5355093
php_redis.dll 扩展 For PHP5.4.x
PHP5.4.x 的 redis 扩展 php_redis.dll
测试平台:Windows XPx32 (FastCGI PHP5.4.9 Nginx 1.4.0)
包含 Non Thread Safe 和 Thread Safe 两个版本
首先把php_redis.dll 和 php_igbinary.dll 放入PHP的ext文件夹,然后在php.ini配置文件里添加如下代码:
extension=php_igbinary.dll
extension=php_redis.dll
重启web服务器
注意:extension=php_igbinary.dll一定要放在extension=php_redis.dll的前面,否则此扩展不会生效
4、PHP中使用
代码如下
<?<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></span></span></span></span></span>
输出 hello redis 成功!

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

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

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.

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.