基于centos的redis与php
来源:互联网 发布:软件猎手下载 编辑:程序博客网 时间:2024/06/03 20:28
基于centos的redis与php
这是一个简要操作日记。。。
1、安装
安装phpize。phpize用于生成configure文件,为php扩展模块的编译生成配置文件。
yum install php-devel -y
安装redis
yum install redis -y
从源码安装phpredis
wget https://github.com/nicolasff/phpredis/archive/master.zipunzip master.zipcd phpredis-master/phpize./configuremake && make install && make test
配置php添加扩展
find / -name php.inivi /etc/php.iniGextension="redis.so":wqservice httpd restart # or reboot
测试phpredis
[root@nfvbfqi9 ~]# php -aInteractive shellphp > $redis= new Redis();php > $redis->connect('127.0.0.1',6379);php > $redis->set("pageview",10);php > $k=$redis->get("pageview");php > echo $k;10
2、简单操作
redis
启动redis服务
加$令其后台执行,加()表示在子shell中执行命令,纵然当前shell退出,此服务进程不会被kill。
(redis-server&)
加入开机自启动脚本
注意>表示写文件会清空原有内容,>>表示追加到文件末尾行。
echo "(redis-server&)" >>/etc/rc.local
启动redis命令行
redis-cli #进入redis命令行模式
退出redis命令行
quit
注意不要用shutdown。shutdown命令会关闭当前redis服务,也即kill掉redis服务进程
dbsize #获取记录条数set pageview 0 #设置k:vget pageview #获取k:vdel pageview #删除k:vsave #保存help @generic #DEL key [key ...]summary: Delete a keysince: 1.0.0DUMP keysummary: Return a serialized version of the value stored at the specified key.since: 2.6.0EXISTS key [key ...]summary: Determine if a key existssince: 1.0.0EXPIRE key secondssummary: Set a key's time to live in secondssince: 1.0.0EXPIREAT key timestampsummary: Set the expiration for a key as a UNIX timestampsince: 1.2.0KEYS patternsummary: Find all keys matching the given patternsince: 1.0.0MIGRATE host port key| destination-db timeout [COPY] [REPLACE] [KEYS key]summary: Atomically transfer a key from a Redis instance to another one.since: 2.6.0MOVE key dbsummary: Move a key to another databasesince: 1.0.0OBJECT subcommand [arguments [arguments ...]]summary: Inspect the internals of Redis objectssince: 2.2.3PERSIST keysummary: Remove the expiration from a keysince: 2.2.0PEXPIRE key millisecondssummary: Set a key's time to live in millisecondssince: 2.6.0PEXPIREAT key milliseconds-timestampsummary: Set the expiration for a key as a UNIX timestamp specified in millisecondssince: 2.6.0PTTL keysummary: Get the time to live for a key in millisecondssince: 2.6.0RANDOMKEY -summary: Return a random key from the keyspacesince: 1.0.0RENAME key newkeysummary: Rename a keysince: 1.0.0RENAMENX key newkeysummary: Rename a key, only if the new key does not existsince: 1.0.0RESTORE key ttl serialized-value [REPLACE]summary: Create a key using the provided serialized value, previously obtained using DUMP.since: 2.6.0SCAN cursor [MATCH pattern] [COUNT count]summary: Incrementally iterate the keys spacesince: 2.8.0SORT key [BY pattern] [LIMIT offset count] [GET pattern [GET pattern ...]] [ASC|DESC] [ALPHA] [STORE destination]summary: Sort the elements in a list, set or sorted setsince: 1.0.0TTL keysummary: Get the time to live for a keysince: 1.0.0TYPE keysummary: Determine the type stored at keysince: 1.0.0WAIT numslaves timeoutsummary: Wait for the synchronous replication of all the write commands sent in the context of the cu rrent connectionsince: 3.0.0GEORADIUSBYMEMBER_RO key arg arg arg arg ...options...summary: Help not availablesince: not knownREPLCONF arg ...options...summary: Help not availablesince: not knownSUBSTR key arg arg argsummary: Help not availablesince: not knownPSYNC arg arg argsummary: Help not availablesince: not knownTOUCH key arg ...options...summary: Help not availablesince: not knownPFSELFTEST argsummary: Help not availablesince: not knownGEORADIUS_RO key arg arg arg arg arg ...options...summary: Help not availablesince: not knownPOST arg ...options...summary: Help not availablesince: not knownLATENCY arg arg ...options...summary: Help not availablesince: not knownHOST: arg ...options...summary: Help not availablesince: not knownASKING argsummary: Help not availablesince: not knownRESTORE-ASKING key arg arg arg ...options...summary: Help not availablesince: not knownPFDEBUG arg arg arg ...options...summary: Help not availablesince: not known
Then you know how to do IT.
阅读全文
0 0
- 基于centos的redis与php
- 基于CentOS安装Redis
- CentOS系统安装Redis及Redis的PHP扩展
- CentOS系统安装Redis及Redis的PHP扩展
- 基于Redis的PHP聊天室程序
- Re:admin 基于PHP的redis管理工具
- 基于Redis的消息队列php-resque
- 基于PHP+redis的秒杀系统
- 基于PHP+redis的秒杀实现
- 基于PHP+redis的秒杀系统
- 搭建基于 centos 的 Redis 哨兵模式 (4.0.6)
- centos 安装php扩展redis
- 在CENTOS 7下安装redis + php遇到的问题
- centos安装redis及php-redis扩展
- centos安装redis及php-redis扩展
- centos安装redis和php-redis扩展
- centos 安装redis和php redis扩展
- 基于Nginx+PHP+Redis的短URL系统的实现
- Git 【git代码提交常用命令】
- CCF认证201503-1 图像旋转
- WinDbg F9时“code not found breakpoint not set”
- Tarjan求强连通分量
- 算法4 爬梯子Climbing Stairs
- 基于centos的redis与php
- 自定义用户控件的使用
- win8.1+vs2015环境下,正确启用armadillo的方法
- 【BZOJ3244】【NOI2013】树的计数
- Iterators(关键词:Python/iterator/iterable/__iter__/next)
- Work1
- Eclipse 插件管理
- NYOJ49. 开心的小明(0-1背包)
- 黎活明给程序员的忠告 收藏