This article is the first part of the php-redis Chinese document. it mainly introduces some of the commands officially provided by redis. if you need it, refer to it. This article is the first part of the php-redis Chinese document. it mainly introduces some of the commands officially provided by redis. if you need it, refer to it. As an extension of php, phpredis is highly efficient and has the linked list sorting function, which is useful for creating memory-level module business relationships; : Https://github.com/owlient/phpredis (support for redis 2.0.4) Redis :__ construct $ Redis = new redis (); connect, open link Redis service parameter host: string, service address port: int, port number timeout: float, link duration (optional, default value: 0, unlimited link time) Note: in redis. the conf file also has time. the default value is 300 pconnect, for links that popen does not close, refer to the above setOption settings redis mode getOption view redis mode ping view connection status get a key value (string value) if the key does not exist, return false set write key and value (string value) if the write is successful, return ture setex write value with survival time $ redis-> setex ('key', 3600, 'value'); // sets key → value, with 1 h TTL. setnx indicates whether the request is repeated. the written value $ redis-> setnx ('key', 'value'); $ redis-> setnx ('key', 'value '); delete: returns the number of deleted keys (long integer) $ redis-> delete ('key1', 'key2 '); $ redis-> delete (array ('key3', 'key4', 'key5 ')); ttl: Get the ttl of a key. persist: remove the expired key. if the key expires, true is returned. if the key does not expire, false is returned. |