当前位置: 首页 > 编程日记 > 正文

Redis安装整理(window平台) +php扩展redis

window平台Redis安装 

redis windows安装文件下载地址
:http://code.google.com/p/servicestack/wiki/RedisWindowsDownload#Download_32bit_Cygwin_builds_for_Windows
我选择的redis为最新版的安装文件,见下图: 
 
  
Redis安装文件解压后,有以下几个文件。见下图 

redis-server.exe:服务程序 
redis-check-dump.exe:本地数据库检查 
redis-check-aof.exe:更新日志检查 
redis-benchmark.exe:性能测试,用以模拟同时由N个客户端发送M个 SETs/GETs 查询 (类似于 Apache 的ab 工具). 

在解压好redis的安装文件到E:\根目录后,还需要在redis根目录增加一个redis的配置文件redis.conf,文件具体内容附件中有,不过这里我仍然把配置文件的内容贴上来:

配置文件

[html] view plaincopy
  1. # Redis configuration file example
  2. # By default Redis does not run as a daemon. Use 'yes' if you need it.
  3. # Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
  4. daemonize no
  5. # When run as a daemon, Redis write a pid file in /var/run/redis.pid by default.
  6. # You can specify a custom pid file location here.
  7. pidfile /var/run/redis.pid
  8. # Accept connections on the specified port, default is 6379
  9. port 6379
  10. # If you want you can bind a single interface, if the bind option is not
  11. # specified all the interfaces will listen for connections.
  12. #
  13. # bind 127.0.0.1
  14. # Close the connection after a client is idle for N seconds (0 to disable)
  15. timeout 300
  16. # Set server verbosity to 'debug'
  17. # it can be one of:
  18. # debug (a lot of information, useful for development/testing)
  19. # notice (moderately verbose, what you want in production probably)
  20. # warning (only very important / critical messages are logged)
  21. loglevel debug
  22. # Specify the log file name. Also 'stdout' can be used to force
  23. # the demon to log on the standard output. Note that if you use standard
  24. # output for logging but daemonize, logs will be sent to /dev/null
  25. logfile stdout
  26. # Set the number of databases. The default database is DB 0, you can select
  27. # a different one on a per-connection basis using SELECT <dbid> where  
  28. # dbid is a number between 0 and 'databases'-1
  29. databases 16
  30. ################################ SNAPSHOTTING  #################################
  31. #
  32. # Save the DB on disk:
  33. #
  34. #   save <seconds<changes>  
  35. #
  36. #   Will save the DB if both the given number of seconds and the given
  37. #   number of write operations against the DB occurred.
  38. #
  39. #   In the example below the behaviour will be to save:
  40. #   after 900 sec (15 min) if at least 1 key changed
  41. #   after 300 sec (5 min) if at least 10 keys changed
  42. #   after 60 sec if at least 10000 keys changed
  43. save 900 1
  44. save 300 10
  45. save 60 10000
  46. # Compress string objects using LZF when dump .rdb databases?
  47. # For default that's set to 'yes' as it's almost always a win.
  48. # If you want to save some CPU in the saving child set it to 'no' but
  49. # the dataset will likely be bigger if you have compressible values or keys.
  50. rdbcompression yes
  51. # The filename where to dump the DB
  52. dbfilename dump.rdb
  53. # For default save/load DB in/from the working directory
  54. # Note that you must specify a directory not a file name.
  55. dir ./
  56. ################################# REPLICATION #################################
  57. # Master-Slave replication. Use slaveof to make a Redis instance a copy of
  58. # another Redis server. Note that the configuration is local to the slave
  59. # so for example it is possible to configure the slave to save the DB with a
  60. # different interval, or to listen to another port, and so on.
  61. #
  62. # slaveof <masterip<masterport>  
  63. # If the master is password protected (using the "requirepass" configuration
  64. # directive below) it is possible to tell the slave to authenticate before
  65. # starting the replication synchronization process, otherwise the master will
  66. # refuse the slave request.
  67. #
  68. # masterauth <master-password>  
  69. ################################## SECURITY ###################################
  70. # Require clients to issue AUTH <PASSWORD> before processing any other  
  71. # commands.  This might be useful in environments in which you do not trust
  72. # others with access to the host running redis-server.
  73. #
  74. # This should stay commented out for backward compatibility and because most
  75. # people do not need auth (e.g. they run their own servers).
  76. #
  77. # requirepass foobared
  78. ################################### LIMITS ####################################
  79. # Set the max number of connected clients at the same time. By default there
  80. # is no limit, and it's up to the number of file descriptors the Redis process
  81. # is able to open. The special value '0' means no limts.
  82. # Once the limit is reached Redis will close all the new connections sending
  83. # an error 'max number of clients reached'.
  84. #
  85. # maxclients 128
  86. # Don't use more memory than the specified amount of bytes.
  87. # maxmemory <bytes>  
  88. appendonly no
  89. appendfsync always
  90. glueoutputbuf yes

将附件中的redis_conf.rar解压下来放到redis的根目录中即可。到此,redis的安装已经完毕。下面开始使用redis数据库。 

启动redis: 
输入命令:redis-server.exe redis.conf 
启动后如下图所示: 
 

启动cmd窗口要一直开着,关闭后则Redis服务关闭。 
这时服务开启着,另外开一个窗口进行,设置客户端: 
输入命令:redis-cli.exe -h 202.117.16.133 -p 6379 
输入后如下图所示: 
 

上面的IP写自己的哦:

php扩展Redis功能

1 首先,查看所用php编译版本V6/V9 在phpinfo()中查看

2 下载扩展 地址:https://github.com/nicolasff/phpredis/downloads(注意所支持的php版本)

3 将下载的php_redis.dll放在php扩展目录中(ext),并修改配置文件php.ini

添加 扩展的时候一定要

extension=php_igbinary.dll
extension=php_redis.dll
这个顺序
否则重启Apache的时候会出现,PHP startup 错误

4 重新启动服务,查看phpinfo(),下面表示成功;

5 用PHP测试

Php代码

[php] view plaincopy
    1. $redis = new Redis();  
    2. $redis->connect("192.168.138.2","6379");  //php客户端设置的ip及端口  
    3. //存储一个 值  
    4. $redis->set("say","Hello World");  
    5. echo $redis->get("say");     //应输出Hello World  
    6. //存储多个值  
    7. $array = array('first_key'=>'first_val',  
    8. 'second_key'=>'second_val',  
    9. 'third_key'=>'third_val');  
    10. $array_get = array('first_key','second_key','third_key');  
    11. $redis->mset($array);  
    12. var_dump($redis->mget($array_get));  

相关文章:

WMI技术介绍和应用——查询环境变量

本文使用了《WMI技术介绍和应用——使用VC编写一个半同步查询WMI服务的类》中代码做为基础。 我们可以通过系统属性查看当前系统和当前用户的环境变量。&#xff08;转载请指明出于breaksoftware的csdn博客&#xff09; 如何使用WMI枚举所有环境变量的信息&#xff1f; CSynQue…

想学新的编程语言?考虑下Go吧

作者 | Lewis Fairweather译者 | 弯月&#xff0c;责编 | Elle来源 | CSDN&#xff08;ID&#xff1a;CSDNnews&#xff09;【导读】快速的运行时、高效的并发、简单易学的语法&#xff0c;这些都是Go语言最吸引人的特性。以下为译文&#xff1a;Go语言的入门门槛之低令我感到惊…

oracle学习总结三(bulk collect用法)

通过bulk collect减少loop处理的开销发表人:logzgh | 发表时间: 2006年五月19日, 10:56采用bulk collect可以将查询结果一次性地加载到collections中。而不是通过cursor一条一条地处理。可以在select into,fetch into,returning into语句使用bulk collect。注意在使用bulk coll…

MQTT的学习研究(五) MQTT moquette 的 Blocking API 发布消息服务端使用

参看官方文档&#xff1a; http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/index.jsp?topic/com.ibm.mq.amqtat.doc/tt00000_.htm * Java 为 MQ Telemetry Transport 创建异步发布程序 *在此任务中&#xff0c;您将遵循教程来修改第一个发布程序。通过修改&#xff0c…

WMI技术介绍和应用——查询驱动信息

本文使用了《WMI技术介绍和应用——使用VC编写一个半同步查询WMI服务的类》中代码做为基础。 如何使用WMI查询所有驱动信息&#xff1f;&#xff08;转载请指明出于breaksoftware的csdn博客&#xff09; CSynQueryData recvnotify(L"root\\CIMV2",L"SELECT * FR…

NumericUpDown

NumericUpDown控件主要功能是为一个TextBox控件添加上下按钮&#xff0c;当单击按钮时实现数字的加减&#xff0c;同时也可以提供静态数据&#xff0c;实现这些数据的上下选择。 属性列表&#xff1a; TargetControlID&#xff1a;该控件的目标作用控件。 Width&…

提高建模效率,改变手工作坊式生产,AutoML的技术研究与应用进展如何了?

整理 | 王银出品 | AI科技大本营&#xff08;ID:rgznai100&#xff09;【导读】12 月 5-7 日&#xff0c;由中国计算机学会主办&#xff0c;CCF 大数据专家委员会承办&#xff0c;CSDN、中科天玑协办的中国大数据技术大会&#xff08;BDTC 2019&#xff09;在北京长城饭店隆重举…

.net使用memcached

Windows中memached安装 -------------服务器端配置 1>开始>运行:CMD(确定) 2>cd C:\memcached&#xff08;回车&#xff09; 3>memcached -d install(回车 这步执行安装) 4>memcached -d start(回车 这步执行启动memcache服务器&#xff0c;默认分配64M内存&…

22张精炼图笔记,深度学习专项学习必备

作者 | DL&CV_study9编辑 | Elle来源 | CSDN 博客本文为人工智能学习笔记记录。【深度学习基础篇】一、深度学习基本概念监督学习&#xff1a;所有输入数据都有确定的对应输出数据&#xff0c;在各种网络架构中&#xff0c;输入数据和输出数据的节点层都位于网络的两端&…

WMI技术介绍和应用——查询文件夹信息

本文使用了《WMI技术介绍和应用——使用VC编写一个半同步查询WMI服务的类》中代码做为基础。本节只是列出了WQL语句&#xff0c;具体使用参看前面的例子。 本节主要介绍Win32_Directory类。通过该类我们将可以获得部分常用的文件夹信息。在该类中&#xff0c;有属性Name&#x…

CSLA .NET概述

CSLA是Component-based, Scalable, Logical Architecture的简写&#xff0c;CSLA .NET是Rockford Lhotka基于.Net设计的一套N-tier分布式框架。 CSLA .NET包含如下功能&#xff1a; l n-Level undo capability 译&#xff1a;n层撤销功能 l Tracking broke…

简短的几句js实现css压缩和反压缩功能

写在前面 最近一直在整理css&#xff0c;但因为现在Visual Studio 2013太智能了&#xff0c;它每每在我按ctrlED进行格式化代码的时候&#xff0c;就会将css进行层次格式化&#xff08;如下图所示&#xff09;&#xff0c;而这个格式让我老大实在无法忍受&#xff0c;我老大认为…

迁移学习前沿研究亟需新鲜血液,深度学习理论不能掉链子

作者 | Frederico Guth&#xff0c;Tefilo Emidio de Campos编译 | 夕颜出品 | AI科技大本营(ID:rgznai100)【导读】人类可以从很少的样本中学习&#xff0c;显示出了人类卓越的泛化能力&#xff0c;而这一点学习算法仍远做不到。当前&#xff0c;最成功的模型需要大量标记好的…

WMI技术介绍和应用——查询磁盘分区和逻辑磁盘信息

本文使用了《WMI技术介绍和应用——使用VC编写一个半同步查询WMI服务的类》中代码做为基础。本节只是列出了WQL语句&#xff0c;具体使用参看前面的例子。&#xff08;转载请指明出于breaksoftware的csdn博客&#xff09; 本节主要介绍Win32_DiskPartition和Win32_LogicalDisk两…

用 jQuery 的 AJAX 功能发现的一个错误/注意点:HTTP Error 411

今天程序中有个地方需要 Ajax 方式 POST 数据&#xff0c;发现在 IE 6.0 下正常&#xff0c;而 FireFox 2.0.0.9 下则出错。通过 FireBug 抓取 ajax 回发后得到的页面信息如下&#xff1a;HTTP Error 411 - Length required 经过 google 搜索发现&#xff0c;这个 HTTP 状态码对…

jquery 取消 radio checked 属性,重新选中的问题解决

<input type"radio" name"test"/> <input type"radio" name"test" id "input2"/> (说明&#xff1a;使用的jquery 版本是 1.10.2。) 使用 jquery 的removeAttr(),清除掉 radio 的checked属性后。使用 attr(…

使用×××版软件中常见的一些错误代码

1、错误代码&#xff08;691&#xff09;&#xff1a;由于域上的用户名或密码无效而拒绝访问。如果是使用的易游提供的服务器&#xff0c;请在帐务系统确认使用的帐号是否状态正常&#xff0c;刚设置好的帐号需要等5分钟才能使用。如果是外部服务器请直接找服务器提供商。2、错…

程序员在地铁写代码遭疯狂吐槽!网友:装什么装

01作为了解程序员这个行业的人来说程序员的工作真的很累加班已经成为他们的标签有的时候网站出事或者需求比较紧急的时候可能路边也是他们的工作场地所以这个时候对于程序员们的工作来说也是不分场合的02之前看到网上有人拍到程序员在地铁上写代码的照片并将之发到网络上 图片一…

如何定制一款12306抢票浏览器——构架

快春节了&#xff0c;火车票一票难求。虽然黄牛市场冷淡了&#xff0c;但是互联网“娱乐界”却越来越闹腾了。先是猎豹等浏览器推出抢票专版&#xff08;插件&#xff09;&#xff0c;然后是铁道部约谈金山&#xff0c;之后流传工信部叫停抢票插件&#xff0c;之后再是工信部出…

一些链接, 关于不可变数据

这篇笔记介绍不可变数据, Persistent Data Structure 和 Immutable. 但是不深入数据结构实现, 函数式编程理论. 定义 https://en.wikipedia.org/wiki/Persistent_data_structure In computing, a persistent data structure is a data structure that always preserves the pre…

囚犯学会编程之后会发生什么?

作者 | Simone Stolzoff译者 | 苏本如&#xff0c;责编 | 郭芮出品 | CSDN&#xff08;ID&#xff1a;CSDNnews&#xff09;【导读】Slack是硅谷一家多元化的公司&#xff0c;它雇佣了三名以前被监禁的程序员。但事实上&#xff0c;当一个人从监狱获释时&#xff0c;监禁的耻辱…

如何定制一款12306抢票浏览器——用户界面

用户界面 我不打算写个Windows界面。因为这个软件的全部就是个浏览器。我准备将”浏览器“进行到底&#xff0c;所以我选择使用html作为我们的用户界面。我也并不打算从头开始写一个浏览器&#xff0c;我使用了《内嵌IE网页窗口中消除IE默认脚本设置影响的方法》中基于WTL的浏览…

Study on Android【四】--显示控件使用

Android的界面显示同样也是基于控件的。通常是用View&#xff08;包括ViewGroup&#xff09;控件配上XML的样式来做的。具体细节不想说了&#xff0c;可以参考 Samples里的ApiDemos/View&#xff0c;和View的Doc&#xff0c;以及Implementing a UI这篇Doc。其他还有很多&#x…

修改Vim配色方案

1. 查看备选的配色方案/usr/share/vim/vim74/colors2. 查看当前使用的配色方案在命令模式下输入 :colorscheme可见当前使用的配色方案为ron3.选择和设置配色方法编辑 ~/.vimrc文件&#xff0c;如选择ron.vim对应的配色方案&#xff0c;则添加 colorscheme ron4. 设置某项颜色--…

如何定制一款12306抢票浏览器——启动“人”线程

启动“人”线程 在《如何定制一款12306抢票浏览器——构架》一文中&#xff0c;我们提到“人”线程。对于熟悉Window编程的同学来说&#xff0c;线程间通信和信息传递不是难题。但是由于浏览器和我们“人”线程之间传递的是COM对象&#xff0c;这个过程就没有那么简单了。&…

看看你是《老朋友》(青春六人行)里的哪一个

&#xff08;点击“which friends character are you?”连接可以进入问卷页面&#xff09; Which Friends Character Are You? You are Rachel. Youre very selfish and pay great attention to image. Spoiled when you were young, you were always the popular and sn…

360金融沈赟:只有适配实践的技术才能实现价值掘金

金融科技应用的新场景、新需求层出不穷,已成为创新技术的理想“试验田”。然而当“创新”浪潮褪去&#xff0c;行业回归审慎与冷静后不难发现&#xff0c;并非所有创新技术都会深入金融土壤。对此&#xff0c;360金融首席数据科学家沈赟认为&#xff0c;只有适配实践的技术才能…

swift(一)基础变量类型

import Foundationprintln("Hello, World!")/*int a; */ var a 10 //隐式类型转换 a 9 println(a)let b 10 println(b)/* 类型标注 *///var x:Int //x 10.3不支持隐式转换let x: Int 10/* 名称不用在符合标示符的规范 */ let 常量 10/* 基本数据类型&#xff1…

如何定制一款12306抢票浏览器——实现自动查询和预订功能

检查是否进入订票页面 判断是否进入订票页面&#xff0c;我是确定了两个标准&#xff1a;&#xff08;转载请指明出于breaksoftware的csdn博客&#xff09; 1 网址是否为http://www.12306.cn/mormhweb/kyfw/ 2 该页面否有查询按钮 BOOL CDeal12306WebPage::IsQueryPage( CComPt…

以数据为中心,立足六大技术支柱,英特尔推动神经拟态计算、量子计算前沿探索

近日&#xff0c;英特尔中国研究院院长宋继强围绕 “英特尔如何构建技术基石&#xff0c;驱动未来计算”为主题做了演讲。他阐述了英特尔将坚持“以数据为中心”的目标&#xff0c;并指出依托于XPU产品组合&#xff0c;英特尔通过异构整合和oneAPI软件平台来推动实现超异构计算…