Home > Backend Development > PHP Tutorial > One of the php-redis Chinese documents

One of the php-redis Chinese documents

WBOY
Release: 2016-07-25 09:05:46
Original
1096 people have browsed it
This article is the first part of the Chinese documentation of php-redis. It mainly introduces the usage skills of some commands officially provided by redis. Friends in need can refer to it.

This article is the first part of the Chinese documentation of php-redis. It mainly introduces the usage skills of some commands officially provided by redis. Friends in need can refer to it.

As an extension of PHP, phpredis is very efficient and has a linked list sorting function, which is very useful for creating memory-level module business relationships;

Download address: https://github.com/owlient/phpredis (supports redis 2.0.4)

The following are the command usage tips officially provided by redis: Redis::__construct constructor $redis = new Redis(); connect, open link redis service parameter host: string, service address port: int, port number timeout: float, link duration (optional, default is 0, no limit to link time) Note: There is also time in redis.conf, the default is 300 pconnect, popen will not actively close the link Refer to above setOption sets redis mode getOption View the mode set by redis ping to check connection status get gets the value of a certain key (string value) If the key does not exist, return false set writes key and value (string value) If the write is successful, return true setex write value with time to live $redis->setex('key', 3600, 'value'); // sets key → value, with 1h TTL. setnx determines whether it is repeated and writes the value $redis->setnx('key', 'value'); $redis->setnx('key', 'value'); delete deletes the value of the specified key Returns the number of deleted keys (long integer) $redis->delete('key1', 'key2'); $redis->delete(array('key3', 'key4', 'key5')); ttl Get the survival time of a key persist Remove keys whose lifetime has expired true if the key expires, false if it does not expire



Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template